Re: [NTLK] NewtonScript Question

From: Paul Guyot (pguyot_at_kallisys.net)
Date: Tue Nov 12 2002 - 03:12:00 EST


À (At) 18:21 -0500 11/11/02, Varun Mehta écrivait (wrote) :
>Well, if anyone still cares

If you post the source code, we can help. If you only describe what
happens, we cannot.

Imagine that I say: hey, can you please help, I put an ATA card in
the eMate and then it restarts. :)

>numberInt := Rint(StringToNumber(GetSlot(NumBox, 'text)));

GetSlot isn't really useful here. You can make the code more readable
(IMHO) with:
numberInt := Rint(StringToNumber(NumBox.text));

Also, please note that Rint returns a float number. What you probably
want is RintToL.

>SetValue(ResultText,'text,NumberStr(Random(numberInt,typeInt*numberInt)));

Random expects integers, not floats. So it is probably here that an
exception was thrown. If you had used RintToL, it probably would have
worked.

You could have figured it out by installing NS Debug, connecting the
inspector, compiling your project with debug checked and enabling the
breakpoints in NS Debug. The Newton would have then stopped where the
exception occurred and with dishere() command or by clicking the
stacktrace button, you would have figured out that Random threw that
exception. With args(), you would have seen that it got real numbers.

Another way is to use BugTrap which generates a note. Be sure to
compile your package with debug flag set, because BugTrap also asks
NS Debug to disassemble the code and NS Debug will only do it if the
code was compiled with debug flag set.

Paul

-- 
NPDS: http://newton.kallisys.net:8080/
Apache: http://www.kallisys.com/

-- This is the NewtonTalk list - http://www.newtontalk.net/ for all inquiries List FAQ/Etiquette/Terms: http://www.newtontalk.net/faq.html Official Newton FAQ: http://www.chuma.org/newton/faq/



This archive was generated by hypermail 2.1.2 : Mon Dec 02 2002 - 22:02:32 EST