? System Variables are not "variables" ● SmileBASIC Source

Sign In

Register
*Usernames are case-sensitive
Forgot my password

System Variables are not "variables"

A system variable is not defined and stored as a proper variable the same way all other vars are. For example, CHKVAR will always return false (0) for a system variable—even a writeable one. In addition, accessing a system variable through functional VAR will throw Undefined variable. Take the following prompt as an example (lines starting with > are DIRECT input, all others are output.) >PRINT CHKVAR("MAINCNT") 0 OK >PRINT VAR("CSRX") Undefined variable OK >VAR A%=10 OK >PRINT CHKVAR("A%") 1 OK >PRINT VAR("A%") 10 OK This leads to the conclusion that system variables are specially compiled keywords and not variables which point to some static system value; even writeable ones probably compile to a special assignment instruction when writing. This also possibly confirms the suspicion that TRUE and FALSE are complied keywords which simply represent 1 and 0, instead of being true variables themselves, making their associated constants redundant.
Author
snail_
Updated
Rating
5 votes
Categories
Keywords
  • system
  • variable
  • docs
  • spec
10 Comment(s) 12Me21 12Me21 Power User Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself Ok so it's been like 7 years and we know more about SB now Yes system vars are variables; they use the same addressing mode in the compiled bytecode. Also: VAR MAINCNT is a duplicate variable error You can use VAR MAINCNT in a function, which creates a local variable that is completely separate from the global system var. VAR( and CHKVAR just only check user defined variables (maybe this is a bug, or maybe it's intentional. it's hard to tell especially when VAR() isn't even documented) snail_ snail_ QSP Contest 1 Contest Participant I participated in the first SmileBASIC Source QSP Contest! Helper Received for being very helpful around SmileBASIC Source Achievements Amazing Contributor Someone thinks I'm an awesome person who has done so much for the community! Achievements I hereby denounce my use of #TRUE in favor of TRUE. Semantics and best practice wins. Speed tests between both demonstrate they both run at the same speed. 12Me21 12Me21 Power User Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself #YES and #OK are much better lol. Though !-. is pretty good too. snail_ snail_ QSP Contest 1 Contest Participant I participated in the first SmileBASIC Source QSP Contest! Helper Received for being very helpful around SmileBASIC Source Achievements Amazing Contributor Someone thinks I'm an awesome person who has done so much for the community! Achievements I hereby denounce my use of TRUE in favor of #TRUE 12Me21 12Me21 Power User Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself R.I.P. TRUE hakke hakke RNG Hidden Easter Eggs Third Year My account is over 3 years old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength ohmigosh 12Em43 im ur biggest fan i luv u everything is fair in the love of 15You32 will u marry mi sozz please rando rando Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Second Year My account is over 2 years old Website Forum Leader Hidden Achievements bananana why are you acting so weird? hakke hakke RNG Hidden Easter Eggs Third Year My account is over 3 years old Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength because im fucking stupid and i dont know what to do with my fucking life rando rando Intermediate Programmer I can make programs, but I still have trouble here and there. Programming Strength Second Year My account is over 2 years old Website Forum Leader Hidden Achievements What? Why would you ever think that? That is, if you actually think that and aren't just trying to joke around. 12Me21 12Me21 Power User Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself oh-