Page 1 of 1

Request: additional feature to SubStr action

PostPosted: Tue Jul 17, 2012 7:29 am
by dpayer
I find I am doing the following very often:

Parsing a large string

Get a portion of one of the lines that were parsed from that larger string starting at a delimiter.

So when I use the SubStr action, I need to determine the length of that parsed string before I can start at position [X] and get all characters between that point and the end of the substring.

Would it be possible to have the SubStr action have the option to get ALL the remaining portion of a string from the point you start?

Something like:

Code: Select all
SubStr "[mystring]" "5" "END" "[mystring]"


If this already exists, I have missed it. I know I could put in some very long number beyond what I 'expect' the string to be but that invites a problem.

Thanks for listening.

David P.

PostPosted: Tue Jul 17, 2012 9:10 am
by Wrangler
Couldn't you use strlen to determine the length of the string first? Then the 'end' would be the length of the string.

PostPosted: Tue Jul 17, 2012 9:44 am
by dpayer
Wrangler wrote:Couldn't you use strlen to determine the length of the string first? Then the 'end' would be the length of the string.


Yes, I admit I could. So there is a way to do what I want with a couple extra steps. Since I do alot with strings, it is one extra step each time.

Note: this is not what I would consider a problem. It is a feature request. If it fits on that (huge) list of desired enhancements somewhere and seems feasible to Dave, I'd vote for it!

8)

David

PostPosted: Tue Jul 17, 2012 9:51 am
by Wrangler
I do a lot of string manipulation also. This WOULD be a nice extra feature to have in this action. My vote is for it. In the meantime, I just call it as a function.

It would be very useful when parsing html, which has always been a bear. Then it would save a lot of 'extra' actions.

PostPosted: Tue Jul 17, 2012 9:54 am
by dec
Hello,

If I can say something, David, think that others environment like Delphi, for example, put the same basic string routines: pos, len, sub, copy, etc. that NeoBook. Of course, via plugins, you can get certain useful string routines additions, and, also you can use many of this string routines on a NeoBook function, for example.

And this is the "normal way", better said, normally you (not only in NeoBook, also in others environments) can use, reuse and multi-use the basic routines in order to compound your more specific functions, who use the basic routines. In my honest opinion (in normal circumstances) you no need to worry about if this basic routines: pos, len, sub, etc., need to be called one or more times.

Of course you know a good practice is, for example, to use the "len" routine only one time (when possible) saving the result in a variable that later we can continue using instead of calling the "len" routine again. But out of this cases, you no need to worry to prepare, for example, a "MyCustomStringFunction" function that use the basic string routines in order to get the desired results. ;)

PostPosted: Tue Jul 17, 2012 10:35 am
by Neosoft Support
You can overstate the length of the string and SubStr will stop when it reaches the end. For example:

SubStr "[mystring]" "5" "10000" "[mystring]"

PostPosted: Tue Jul 17, 2012 4:55 pm
by dpayer
Neosoft Support wrote:You can overstate the length of the string and SubStr will stop when it reaches the end. For example:

SubStr "[mystring]" "5" "10000" "[mystring]"


Thanks for the suggestion!

David P

PostPosted: Wed Jul 18, 2012 11:13 am
by reinier maliepaard
Hello David,

You can also use the VBScript MID function. A quick test: insert the follwing code between the <head></head> of your html page and view the page in Internet Explorer:

<script type="text/vbscript">

txt="This is a beautiful day!"
document.write(Mid(txt,11))

</script>

Regards,
Reinier