LiveCode Builder is a language for extending LiveCode's capabilities, creating new object types as Widgets, and libraries that access lower-level APIs in OSes, applications, and DLLs.
Moderators: LCMark, LCfraser
-
Zryip TheSlug
- VIP Livecode Opensource Backer
- Posts: 163
- Joined: Tue Jan 26, 2010 10:15 pm
-
Contact:
Post
by Zryip TheSlug » Mon Apr 06, 2015 9:49 pm
If I'm following the "format" documentation about casting a numeric as a string
Code: Select all
public handler myHandler()
variable tNum as Number
variable tNumString as String
put 5 into tNum
format tNum as string
put the result into tNumString
log tNumString
end handler
The result is not 5 but 5.000000 even if the variable tNum is defined as an Integer.
if we have this handler
Code: Select all
public handler myHandler()
variable tNum as Number
put 5 into tNum
log tNum
end handler
The result is 5
If we are introducing a loop:
Code: Select all
public handler myHandler()
variable tLine as Integer
repeat with tLine from 1 up to 3
log tLine
end repeat
end handler
The result is:
1
2.000000
3.000000
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel
-
trevordevore
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
-
Contact:
Post
by trevordevore » Mon Apr 06, 2015 10:02 pm
This is a known issue. For the time being, @LCMark gave me his handler to use when formatting a number as a string and you just want the integer representation.
Code: Select all
handler FormatInt(in pNumber as Number) returns String
variable tNumberString as String
put pNumber formatted as string into tNumberString
if "." is in tNumberString then
variable tDotOffset
put the first offset of "." in tNumberString into tDotOffset
delete char tDotOffset to (the number of chars in tNumberString) of tNumberString
end if
return tNumberString
end handler
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder
-
Zryip TheSlug
- VIP Livecode Opensource Backer
- Posts: 163
- Joined: Tue Jan 26, 2010 10:15 pm
-
Contact:
Post
by Zryip TheSlug » Tue Apr 07, 2015 7:44 pm
Thanks for sharing, Trevor.
TheSlug
http://www.aslugontheroad.com - Tutorials, demo stacks and plugins for LiveCode
Data Grid Helper - An intuitive interface for building LiveCode's Data Grids
Excel Library- Extends the LiveCode language for controlling MS Excel
-
peter-b
- Posts: 182
- Joined: Thu Nov 20, 2014 2:14 pm
- Location: LiveCode Ltd.
Post
by peter-b » Tue Apr 07, 2015 9:31 pm
trevordevore wrote:This is a known issue. For the time being, @LCMark gave me his handler to use when formatting a number as a string and you just want the integer representation.
That was me, but I'm flattered to be confused with @LCMark.
Unfortunately this has turned out to be an (even) more challenging fix that we expected, so I'm afraid it won't be fixed in 8.0.0-dp-2. Sorry.
LiveCode Open Source Team — @PeterTBBrett — peter.brett@livecode.com
-
trevordevore
- VIP Livecode Opensource Backer
- Posts: 1005
- Joined: Sat Apr 08, 2006 3:06 pm
- Location: Overland Park, Kansas
-
Contact:
Post
by trevordevore » Tue Apr 07, 2015 10:20 pm
@peter-b - AKA @LCMark
Trevor DeVore
ScreenSteps - https://www.screensteps.com
LiveCode Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode
LiveCode Builder Repos - https://github.com/search?q=user%3Atrevordevore+topic:livecode-builder