Formatting decimals, global/local variables, and compiling

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Josh
Posts: 46
Joined: Sat Jan 12, 2008 6:42 am

Formatting decimals, global/local variables, and compiling

Post by Josh » Mon Feb 04, 2008 7:24 am

Hi all,

Two questions:

1. Is there a way to format real numbers to 4 decimal places? I found %[charLength]d but that only rounds to whole numbers. I'm interested in the decimals, just truncated or rounded to 4 places beyond the decimal point.

2. I love Rev's ability to permit local variable to be used willy nilly. However, is there a quick and dirty way to assess whether all global variable have been identified as such in the necessary handles? I've had several rather long debug sessions due to my
A. forgetting to declare global variable in both handles
B. switching a variable name at some point making it become a local variable that was never meant to be one (global: testType accidentally becoming trialType)
C. finding the appropriate handle to "compile" in

During compile, Delphi would tell me where all undeclared variables were. Even sweeter, Delphi would tell me what variable went unused and could be deleted from the declarations.

Lastly, is there a way to compile all handles at once rather than my having to compile within each handle?

Thanks all,
Josh

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Mon Feb 04, 2008 11:27 am

Dear Josh,

1) Two examples, returning "9.00":

Code: Select all

set the numberformat to "0.00"
put 9*1 -- any calculation will do
or

Code: Select all

put format("%.2f",9)


2) There is no way for Rev to know that an undeclared local variable was actually meant to be global. You might set the explicitVariables to true, but this will make it necessary to declare all local variables as well. Thus the answer is no.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply