I managed to confuse myself earlier while writing the "MyMillis" file I've been using for timing while I struggle to get the "master" version of 'millis.h' to work on the 16F1829.
I include this in a script and it failed to work as I expected:
#ScriptIfChipMHz=64ThenLetFrequencyIncluded=1LetMyPreLoad=49356'Preload Timer for 1mS @ 64MHzEndIf...Otherstatementsfollowedforotherfrequencies#EndScript
When it failed to work I was more than confused for some time before I found that using the "Let" statement rendered the assignments null and void.
This works:
#ScriptIfChipMHz=64ThenFrequencyIncluded=1MyPreLoad=49356'Preload Timer for 1mS @ 64MHzEndIf...Otherstatementsfollowedforotherfrequencies#EndScript
I presume this is due to the compiler treating the named "variables" as contants which also do not require a "Let" statement. However, "Contants" when instantiated with "#Define" also don't use the equals sign.
Not sure it is an error, more likely intended behaviour, but perhaps it could be noted in the online help? Took me three hours to work it out...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried putting let var= a few times in a working program using gcstudio with no problems so a script thing maybe.
edit.. let... nostalgia... zx spectrum with let key
Last edit: stan cartwright 2022-05-08
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"Let" within a program or a Sub seems fine, it was only as I tried to get "clever" with another program that I thought: #Script ... #EndScript might be useful. It confused me that it works within a program, but not in a #Script ... #EndScript. No errors were shown, the help file doesn't mention that script variables (or constants) won't be set when using "Let". It makes explicit reference to floating point values, but not "Let".
As ever I thought I'd mention it as it may confuse someone else. And perhaps if it could be mentioned in the help file too?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
"Let" not only fails to work as intended when used within #Script ... #EndScript, it fails to show any errors regarding this, nor is it recorded in any documentation.
It may well be "right" but I do think it should be highlighted, as the assignment of floating point values is.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
At the least a mention in the help files would have saved me a number of hours confusion.
I did say that I assumed it was intended behaviour, although as "Let" is allowed (if frowned upon) elsewhere in assignment statements I had no reason to initially doubt using it within a #Script ... #EndScript construct.
Hopefully me mentioning this will be all that is needed to help other users and relieve some of the backlog.
I still like to use "Let" as it helps me to see that I am making an assignment of a value as opposed to comparing a value in someway. I liked the Pascal syntax of using ":=" for assignment and "=" for equality testing. It helps me focus.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Resolved in build 1116. See attachment for resolution.
Use of LET in scripts is now trapped. Can not use LET in scripts. Scripts can only create CONSTANTS
Code Segment
#ScriptIfChipMHz=64ThenLETFrequencyIncluded=1MyPreLoad=49356'Preload Timer for 1mS @ 64MHzEndIfIfChipMHz=32ThenLETFrequencyIncluded=1MyPreLoad=49356'Preload Timer for 1mS @ 64MHzEndIf#EndScript
Errors messages
Great Cow BASIC (0.99.02 2022-04-27 (Windows 64 bit) : Build 1116)
Compiling c:\temp\New.gcb ...
Errors have been found:
New.gcb (10): Error: Can not use LET in scripts. Scripts can only create
CONSTANTS
New.gcb (15): Error: Can not use LET in scripts. Scripts can only create
CONSTANTS
The message has been logged to the file Errors.txt.
I managed to confuse myself earlier while writing the "MyMillis" file I've been using for timing while I struggle to get the "master" version of 'millis.h' to work on the 16F1829.
I include this in a script and it failed to work as I expected:
When it failed to work I was more than confused for some time before I found that using the "Let" statement rendered the assignments null and void.
This works:
I presume this is due to the compiler treating the named "variables" as contants which also do not require a "Let" statement. However, "Contants" when instantiated with "#Define" also don't use the equals sign.
Not sure it is an error, more likely intended behaviour, but perhaps it could be noted in the online help? Took me three hours to work it out...
I tried putting let var= a few times in a working program using gcstudio with no problems so a script thing maybe.
edit.. let... nostalgia... zx spectrum with let key
Last edit: stan cartwright 2022-05-08
"Let" within a program or a Sub seems fine, it was only as I tried to get "clever" with another program that I thought: #Script ... #EndScript might be useful. It confused me that it works within a program, but not in a #Script ... #EndScript. No errors were shown, the help file doesn't mention that script variables (or constants) won't be set when using "Let". It makes explicit reference to floating point values, but not "Let".
As ever I thought I'd mention it as it may confuse someone else. And perhaps if it could be mentioned in the help file too?
Are you saying - Let is not supported in Scripts. That sounds about right to me.
I am indeed saying that.
"Let" not only fails to work as intended when used within #Script ... #EndScript, it fails to show any errors regarding this, nor is it recorded in any documentation.
It may well be "right" but I do think it should be highlighted, as the assignment of floating point values is.
I will add this to the backlog of work.
LET should be rejected with an appropriate syntax error message.
At the least a mention in the help files would have saved me a number of hours confusion.
I did say that I assumed it was intended behaviour, although as "Let" is allowed (if frowned upon) elsewhere in assignment statements I had no reason to initially doubt using it within a #Script ... #EndScript construct.
Hopefully me mentioning this will be all that is needed to help other users and relieve some of the backlog.
I still like to use "Let" as it helps me to see that I am making an assignment of a value as opposed to comparing a value in someway. I liked the Pascal syntax of using ":=" for assignment and "=" for equality testing. It helps me focus.
Resolved in build 1116. See attachment for resolution.
Use of LET in scripts is now trapped. Can not use LET in scripts. Scripts can only create CONSTANTS
Code Segment
Errors messages
Last edit: Anobium 2022-05-10