scripting strings
-
- Regular
- Posts: 315
- Joined: 02 Nov 2013 11:19
Re: scripting strings
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...
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
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
But it didnt lol! Obviously subarray doesnt work on strings
Re: scripting strings
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)
-
- Regular
- Posts: 315
- Joined: 02 Nov 2013 11:19
Re: scripting strings
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.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)
Re: scripting strings
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!
I'll check it out in a Lemur template and report back!
Re: scripting strings
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
See....this one is NOT converted into a string:
Code: Select all
answer = num+'.'+frac;
Code: Select all
answer =''+ num+'.'+frac;
And here is an example
- Attachments
-
- oldgear-fraction.jzml
- (2.99 KiB) Downloaded 65 times
-
- Regular
- Posts: 315
- Joined: 02 Nov 2013 11:19
Re: scripting strings
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.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:Code: Select all
answer = num+'.'+frac;
(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)Code: Select all
answer =''+ num+'.'+frac;
And here is an example
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
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
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