numberformat, trunc and round
jbv at souslelogo.com
jbv at souslelogo.com
Tue Feb 2 10:15:24 EST 2021
Hi list,
This might sound like a dumb question, but I'm scratching my head trying
to find a workaround.
I have this portion of script :
set numberformat to "#.0000000"
if myvar = trunc(myvar) then
get myarray[myvar]
end if
The problem seems to be that when numberformat is set, both trunc() and
round()
keep the fractional part of myvar (2.000000); and since the indexes of
myarray
are integers (1,2,3,etc), "get myarray[myvar]" always returns empty...
And I need to set numberformat to "#.0000000", because there are some
rather
complex computations processed with the values in myarray inside a main
loop.
And for various other reasons I can't use indexes with fractional part
in the
array.
Of course, I could use :
set numberformat to "#.0000000"
set itemdelimiter to "."
if myvar = trunc(myvar) then
get myarray[item 1 of myvar]
end if
But that's not very elegant and slows down the script a bit...
Any help would be much appreciated.
Best,
jbv
More information about the use-livecode
mailing list