Post Reply 
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;
Find all posts by this user
Quote this message in a reply
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 ?.


EXPORT TEST()
BEGIN
LOCAL TIC;

PRINT();

REPEAT
TIC=TICKS();
TIC=TIC/1000;
PRINT(TIC);
UNTIL GETKEY >-1;
END;

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
Visit this user's website Find all posts by this user
Quote this message in a reply
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()
BEGIN
  LOCAL TIC;
  RECT();

  REPEAT 
    TIC:=TICKS()/1000;
    TEXTOUT_P(STRING(TIC),0,0,0,0,100,#FFFFFF);
  UNTIL GETKEY>-1;

END;
Find all posts by this user
Quote this message in a reply
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 ?.


EXPORT TEST()
BEGIN
LOCAL TIC;

PRINT();

REPEAT
TIC=TICKS();
TIC=TIC/1000;
PRINT(TIC);
UNTIL GETKEY >-1;
END;

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

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
Find all posts by this user
Quote this message in a reply
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']
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()
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
Find all posts by this user
Quote this message in a reply
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.
Find all posts by this user
Quote this message in a reply
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 ??

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.

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 Smile

Regards
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)