QB64.org Forum
Active Forums => QB64 Discussion => Topic started by: Dimster on July 08, 2021, 12:12:54 pm
-
Often using key words as variables don't work well. I've been using FILE as in "For File = 1 to 50:Do Something:Next " and so far everything has been fine. Is FILE a key word?
-
as long as you do not add a 's' to it your fine, as FILES is a keyword but not FILE.
-
And if it ever becomes a filet, then make sure to invite me. I'll bring a bottle of wine.
-
And if it ever becomes a filet, then make sure to invite me. I'll bring a bottle of wine
:-)
-
You would all be invited. Thanks, I'll keep an eye on my S.
-
Filet? I usually put a lot of stock in what Fell has to say, but this time he may be mis-steak-en.
Pete
-
Dimster was trying to find out if a potential keyword could be used as a variable... and now you have all made me hungry! Well... there goes my schoolboy figure! I hope that you are all happy!
Dimster. Cobalt is correct. Ignore all the other guys... unless they are willing to share recipes.... lol
-
I don't want to tenderize it to death, but the meat-too movement will not be ignored!
Pete
-
use Y
for FILY=1 to ...
...
if ... then goto NEXTY
...
NEXTY: next FILY
Z is also usefull...
-
Often using key words as variables don't work well. I've been using FILE as in "For File = 1 to 50:Do Something:Next " and so far everything has been fine. Is FILE a key word?
why not use "F" or name of file (or genre)
for f_database = bla bla
for db_file (reversing might be safer if you have to use "file")
for game_score_file =bla bla
Sometimes when using a var close to a keyword - on rare occasions it actually works but produces problems that are difficult to find because there is no error in the IDE. This situation is not common, but why risk it - especially when your one character away FILE(S)
-
I haven't tried this but I guess this holds true for all the Key words ..Printt, Forr, Nextt, or Prints, Fors, Nexts even Too as a variable ...I like Loopy .. but as xra7en has just pointed out, the variable maybe too close to the key word.
-
"Is 'file' a key word?"
No. If you want to use it as a variable, go for it...
The closest commands would be "FILES" (report a list of files in a directory) or _FILEEXISTS(filename$) (check if a file filename$ exists)
J
-
I haven't tried this but I guess this holds true for all the Key words ..Printt, Forr, Nextt, or Prints, Fors, Nexts even Too as a variable ...I like Loopy .. but as xra7en has just pointed out, the variable maybe too close to the key word.
One thing to consider in variable names in a large program is search-ability. opens is okay to use as a variable name, but when you search for OPEN to find file operation statements, you need to match case or search for the exact word, otherwise you end up finding all the opens variables, too.
For files, I use f1$, f2$, etc. or myfile$
Also, I think ending a string variable with an "s" looks a bit weird when followed by the dollar sign... opens$. Others may feel differently, but as we all know, my opinion is the only one that counts... in my opinion.
Pete