Page 2 of 2
Re: scripting strings
Posted: 23 Jun 2014 12:30
by oldgearguy
I had a second method, but I really need to key it into the editor and see if it runs.
The basic idea is to turn a number into a string, then subarray it:
strNum = ''+num; // concatenating a null string to a number turns it into a string
answer = subarray(strNum, 0, sizeof(strNum) - 3);
Given that subarray() and sizeof() work on arrays and not strings, this idea might need tweaking...
Re: scripting strings
Posted: 23 Jun 2014 16:07
by Softcore
Just checked this last one because if it worked it would be a great revelation.......
But it didnt lol! Obviously subarray doesnt work on strings
Re: scripting strings
Posted: 23 Jun 2014 16:08
by Softcore
There are of course a lot of ways to create a script but it all depends on what exactly is the expected range of our value....that 1.38974934 got me wondering (seeing > 1)
Re: scripting strings
Posted: 23 Jun 2014 16:43
by oldgearguy
Softcore wrote:There are of course a lot of ways to create a script but it all depends on what exactly is the expected range of our value....that 1.38974934 got me wondering (seeing > 1)
I think my script will handle any possible numeric value. That's why I treated the whole number part and fractional part separately and then glued them back together around the decimal point at the end.
Re: scripting strings
Posted: 23 Jun 2014 17:10
by Softcore
Oh yes, your first one, most definitely - I was thinking something along your second approach......
I'll check it out in a Lemur template and report back!
Re: scripting strings
Posted: 24 Jun 2014 06:19
by Softcore
OK, I can confirm the first solution of Oldgearguy works with a slight change in the manual script....
See....this one is NOT converted into a string:
THIS ONE though is:
(for some reason, Lemur string concatenation assumes a summed variable to be a string, only when the first element of the concatenation is a string)
And here is an example
Re: scripting strings
Posted: 24 Jun 2014 09:24
by oldgearguy
Softcore wrote:OK, I can confirm the first solution of Oldgearguy works with a slight change in the manual script....
See....this one is NOT converted into a string:
THIS ONE though is:
(for some reason, Lemur string concatenation assumes a summed variable to be a string, only when the first element of the concatenation is a string)
And here is an example
Thanks for checking and correcting. Funny -- I had written it the first way initially then deleted it thinking I had done string cats before without the first part being a string.
I haven't been home much and can't install/run the Lemur editor at work, so I appreciate you taking the time to punch it in and fix it.
Re: scripting strings
Posted: 24 Jun 2014 10:50
by Softcore
No worries!
On the (ironic) contrary, after some stupid false procedures of telecommunication companies, Im left with no internet connection at home, possibly for the next 10 - 15 days too. Thank God there's internet and a few spare moments at my workplace. Of course laptop at work also has Lemur editor installed