New to programming...help !
|
05-18-2015, 10:39 PM
Post: #1
|
|||
|
|||
New to programming...help !
Tried to print ticks divided by 1000 yet get a line of zero's ?. What is wrong with the below ?. Also what is the command to print at a particular location on the screen ?.
EXPORT TEST() BEGIN LOCAL TIC; PRINT(); REPEAT TIC=TICKS(); TIC=TIC/1000; PRINT(TIC); UNTIL GETKEY >-1; END; |
|||
05-19-2015, 02:46 AM
Post: #2
|
|||
|
|||
RE: New to programming...help !
(05-18-2015 10:39 PM)Digitaldreams Wrote: Tried to print ticks divided by 1000 yet get a line of zero's ?. What is wrong with the below ?. Also what is the command to print at a particular location on the screen ?. I'm not sure why TIC=TICKS() produces a zero result. However, the following will get what I think you want: EXPORT TEST() BEGIN PRINT(); REPEAT PRINT(TICKS/1000); UNTIL GETKEY >-1; END; Eddie |
|||
05-19-2015, 03:22 AM
(This post was last modified: 05-19-2015 03:25 AM by Didier Lachieze.)
Post: #3
|
|||
|
|||
RE: New to programming...help !
(05-18-2015 10:39 PM)Digitaldreams Wrote: Tried to print ticks divided by 1000 yet get a line of zero's ?. What is wrong with the below ?. Also what is the command to print at a particular location on the screen ?. You got a line of zero's because you used "TIC=" instead of "TIC:=". PRINT is printing to the terminal with each PRINT being on a different line, so if you want to print to a particular location on the screen you should use TEXTOUT_P instead of PRINT: Code: EXPORT TEST() |
|||
05-19-2015, 05:58 AM
Post: #4
|
|||
|
|||
RE: New to programming...help !
(05-19-2015 02:46 AM)Eddie W. Shore Wrote:(05-18-2015 10:39 PM)Digitaldreams Wrote: Tried to print ticks divided by 1000 yet get a line of zero's ?. What is wrong with the below ?. Also what is the command to print at a particular location on the screen ?. Thanks Eddie...believe it or not that was my first attempt and it didn't work, now it does !?. Maybe the recent firmware update did the trick.... Regards |
|||
05-19-2015, 06:18 AM
Post: #5
|
|||
|
|||
RE: New to programming...help !
(05-19-2015 03:22 AM)Didier Lachieze Wrote: [quote='Digitaldreams' pid='35504' dateline='1431988787'] You got a line of zero's because you used "TIC=" instead of "TIC:=". PRINT is printing to the terminal with each PRINT being on a different line, so if you want to print to a particular location on the screen you should use TEXTOUT_P instead of PRINT: [code]EXPORT TEST() BEGIN LOCAL TIC; RECT(); REPEAT TIC:=TICKS()/1000; TEXTOUT_P(STRING(TIC),0,0,0,0,100,#FFFFFF); UNTIL GETKEY>-1 ; END;[/code ] [/quote ] Thanks Didier......I shortened it too by removing TIC altogether. What is the function of ':' after a variable ?? Regards |
|||
05-19-2015, 06:36 AM
(This post was last modified: 05-19-2015 06:41 AM by Didier Lachieze.)
Post: #6
|
|||
|
|||
RE: New to programming...help !
(05-19-2015 06:18 AM)Digitaldreams Wrote: What is the function of ':' after a variable ?? With "TIC=TICKS()" you get the result of the test "TIC equal TICKS()" which in your case in false (zero). With "TIC:=TICKS()" you assign the value of TICKS() to the the variable TIC, it's the same as with the Sto command "TICKS()▶TIC" where you store the value to TICKS() into the TIC variable. So in your original program you were comparing TIC to TICKS(), then TIC to TIC/1000 but never assigning a value to TIC, so the default value (zero) assigned to TIC at its creation by the "LOCAL TIC;" statement was printed. |
|||
05-19-2015, 06:55 AM
Post: #7
|
|||
|
|||
RE: New to programming...help !
(05-19-2015 06:36 AM)Didier Lachieze Wrote:(05-19-2015 06:18 AM)Digitaldreams Wrote: What is the function of ':' after a variable ?? Thanks again Didier !....I'm sure with other devices I've used, if you want to comparison test you would enter '==' !, no wonder It confused me Regards |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)