LoginLogin

What should the first lines of a program look like?

Root / Programming Questions / [.]

SamCreated:
We all know about important commands to use at the beginning of a program, like ACLS and BGMSTOP, but there are more of them that aren't known just as much. Some people don't mind about them and end up with unstable programs, while some others (like me) use too many of them and end up with repetitions everywhere in their program. So what is the perfect mix of commands? I'd like to know your thoughts. https://miiverse.nintendo.net/posts/AYMHAAACAAADVHkooaO-Jw Here's a Miiverse post I made about it.

What you should do at the beginning of every program is ACLS:BGMSTOP:XSCREEN 2:SYSBEEP=0:OPTION STRICT and then follow up with setting up your variables using VAR. After that, you are pretty much good to go.

Thanks, that's a good question, especially for a noob like me. I have only been using ACLS,and BGMSTOP. Though I might not need those other things until I start making more advanced programs.

What you should do at the beginning of every program is ACLS:BGMSTOP:XSCREEN 2:SYSBEEP=0:OPTION STRICT and then follow up with setting up your variables using VAR. After that, you are pretty much good to go.
There are a lot more commands that aren't mentioned in your code, though! For example, I just figured out yesterday that BGMCLEAR was a thing. Did you mean that only the commands in your quote are useful for programs in general? I think there's more commands that could be used to truly get everything back to default (But I could be wrong.) Does someone have a list of every command that is able to bring something back to default? I'm talking about SPCLR, BGCLR, GCLS, but I'm also talking about VISIBLE, XSCREEN, GPRIO, etc. Thank you for the replies. I wish to help those who also wonder what is good to use on the first lines of a program and what isn't.

Actually, I knew about all of those commands. You just asked what would be good in general. Using BGMCLEAR would be good if you are using custom BGM or MML.

From the manual, ACLS is defined as
XSCREEN 0
LOAD "GRP4:SYS/DEFSP.GRP"
LOAD "GRP5:SYS/DEFBG.GRP"
FONTDEF
SPDEF
DISPLAY 1
WIDTH 8
BACKCOLOR 0
FADE 0
COLOR 15,0:LOCATE 0,0,0:ATTR 0:CLS
GPAGE 1,1:SPPAGE 4:BGPAGE 5
VISIBLE 1,1,1,1
DISPLAY 0
BACKCOLOR 0
FADE 0
WIDTH 8
COLOR 15,0:LOCATE 0,0,0:ATTR 0:CLS
FOR I=0 TO 3:GPAGE I,I:GCLS 0:NEXT
GPAGE 0,0:GPRIO 1024
SPPAGE 4:SPCLR
BGPAGE 5:BGCLR
VISIBLE 1,1,1,1
If you're using ACLS, you don't want to also do these. If you don't want all of these, it might be best to write a different set. Heck, you could even define it as a custom command and call MYACLS or something in the beginning.