+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2008
    Location
    ATX
    Posts
    1,545
    Points
    1,588,504.65
    Rep Power
    219

    Default [Calc] Creating the program - common commands and how to use them

    This guide will go over all the commands that you should need to start out making your own programs.

    First, a helpful step would be to add this to the first line of your program so it will show up on MirageOS. This is how you would see it in Graph Link, so if you're thinking about how it would look on the calculator, add another colon at the beginning.
    Code:
    :"Add a comment here
    the colon and quotation mark are what makes your program show up in MirageOS. you can choose to add a comment that will be shown at the bottom of MirageOS, or you can just leave the comment part blank and it will say "BASIC program: XXXXXXXX" where the x's are your program's name. it's up to you.

    also, since i mentioned comments, here's how you add them. It's quite simple. Say I wanted to add a comment that says "this is a comment." here's what it would look like:
    Code:
    this is a comment.
    easy right? i think so too. all you have to do is type in your comment. since the calculator doesn't see a command before it in that line it ignores it.

    Now, let's move on to the commands that you will be using.
    First, how do you enter the commands? Well, when using either the calculator or Graph Link, you can press the PRGM button on the keyboard and it will pop up with a menu of the commands. once you get to know the commands you can simply type them in on Graph Link, but you can NOT type commands in using your calculator. i know, that makes you sad, but you're just gonna have to live with it.

    And now, the moment you've all been waiting for (don't worry, i know you haven't) the commands!

    Disp
    This command will display something on the next available line on the screen, you can use it to display either text or a variable. Here's what it would look like if you wanted to display the text "Hello World" and then on the next line the number stored in variable A.
    Code:
    Disp "Hello World"
    Disp A
    So you see how the text was entered in quotation marks while the variable wasn't? that's how the calculator differentiates between text and a variable. Important: you will need to break up the text up into 16 character segments. For example, instead of writing this
    Code:
    Disp "This is a long sentence that will not fit on one line"
    it would look like this
    Code:
    Disp "This is a long","sentence that","will not fit on","one line."
    each time you see the closing quotation mark and then a comma and the beginning quotation mark of another, that means it will start on a new line. Now, i didn't split words up but you can choose to do so if you want 16 characters on each line. (yes, spaces count)

    Pause
    this is a simple command. it simply pauses the program until the user presses enter. this is how you enter it:
    Code:
    Pause
    don't add anything else to this line.

    ClrHome
    this command clears all things currently being displayed on your calculator's screen. it will look like this in your program
    Code:
    ClrHome
    just like pause, don't add anything else to this line.

    Lbl and Goto
    Lbl defines a place in the program for the calculator to go to. Labels can use letters or numbers, and can use a maximum of two digits. while 9A would be a valid label, 101 would not. Goto simply goes to that label. it would look something like this in your program:
    Code:
    Lbl 1
    Goto 1
    this little code snippet defines label 1 and has instructions that fall under label 1: go to label 1. don't do this in your program, all it does is make a loop that doesn't end unless you do one of three things: let the batteries run down, take the batteries out (which is bad because it will clear your RAM if a program is running and you do that) or press the on button to break the program.

    Output
    Output is similar to the Disp command except you can specify exactly where you want the data to start displaying at. If you put something like this in your program
    Code:
    Output(2,3,"Hi"
    starting in the second row, third column, it would display Hi.

    Menu
    This command allows you to create menus for the program user to choose one of two or more options. You first title the menu, then provide option 1, the label to go to if option one is selected, then option two and so on. say you wanted to make a continue menu with yes and no as options. it would look like this.
    Code:
    Menu("Continue?","Yes",1,"No",2)
    continue is the title, yes is the first choice, and it will go to label 1 if that is selected, no is the second choice and the program will go to label 2 if it is selected.

    For
    The for loop is handy for doing something multiple times slightly faster than if you used Lbl and Goto. First, you define a variable that the number of repetitions that has already been done will be stored to. then you enter the number of times each loop will be executed (i just put one here). then you enter the number of times you want the lines inside the for loop to be executed. starting on the next line you enter the commands that you want the program to run inside the loop. Important - you MUST finish this with the End command. Say you wanted the program to display "Hi" 100 times. the loop would look like this.
    Code:
    For(A,1,100)
    Disp "Hi"
    End
    If/Then
    The If/Then commands are helpful if you want different actions to occur in your program. If you wanted to check if a variable had a value of 1 or 2 and then send them to different lables depending on the outcome, it might look something like this.
    Code:
    If A=1
    Then
    Goto 1
    End
    If A=2
    Then
    Goto 2
    End
    notice that at the end of each separate outcome you need the End command. if you didn't have that then your program could possibly continue into the next outcome, depending on how it's written. and you wouldn't want that.

    While
    Basically like If/Then, While pauses the program in that loop until some requirement is met so the program can progress. If you wanted to have the program wait until the variable A had a value of 1 and then move to Lbl 1, you could write something like this.
    Code:
    While A=/0(that's really supposed to be one symbol i just can't figure out how to do it - it means not equal to)
    End
    Goto 1
    this just keeps the calculator in a simple loop until A equals one, then the loop will end and the calculator will go to label 1.

    Input
    You can use input to take a user's input and save it in either a string (strings can be found by pressing VARS then go down to "String..." or into a variable. If you wanted to save the data in text format, the command would look something like this.
    Code:
    Input "Name? ",Str1
    Name? is what the user will be prompted to enter, and the data will be stored in Str1 (string 1).
    If you wanted to store a numerical value it would look like this.
    Code:
    Input "Age? ",A
    The user would be prompted to enter their age, which would then be stored in variable A.

    getKey
    This command waits for a keypress by the user. This can be used as a substitute for the menu. The way that key values are assigned is somewhat confusing so use this program to map things out. it will work for every key, but pressing the on button will cause the program to crash, as it does on all programs, so don't bother making a getKey funtion for it anyways.
    Download the helpful program here.
    Usually, getKey is used in a while loop, and then there are If/then statements kinda like this.
    Code:
    While A=0
    getKey->(this is an actual arrow in the program - press the button that has the letters "STO" and then an arrow on it)A
    End
    If A=11
    .......
    you get the idea.

    prgm
    This command launch another program. Say that you are in a program and you want to launch another program named "B". simply put
    Code:
    prgmB
    in your program and you will.

    Stop
    This stops the program and will give you a "Done" message. it looks like this in program
    Code:
    Stop
    Well, that was an appropriate last command, because this marks the end of this tutorial. Hopefully you understood this, if not don't hesitate to ask.

    ~Written by WMD54
    please do not repost without permission.
    Last edited by WMD54; 10-12-2008 at 12:25 AM.

  2. #2
    Join Date
    Feb 2008
    Location
    New York
    Posts
    3,114
    Points
    2,760,818.34
    Rep Power
    226

    Default

    NICE! +rep(if i can) must have taken ages to write xD

  3. #3
    Join Date
    Jan 2008
    Location
    PA
    Posts
    1,164
    Points
    3,867,299.25
    Rep Power
    220

    Default

    u should make an example of a temperature converting program or units something else useful just a request, NICE JOB on this one!


    Get Vip: »Here«
    Donate: »Here«
    >>List of Compilers<<
    >>SFDM Name Generator<<
    [Owner Of FluidCoding]

  4. #4
    Join Date
    Apr 2008
    Location
    ATX
    Posts
    1,545
    Points
    1,588,504.65
    Rep Power
    219

    Default

    Quote Originally Posted by SonniE View Post
    u should make an example of a temperature converting program or units something else useful just a request, NICE JOB on this one!
    Yeah, soon i'll be posting programs, i just wanted to write a few guides to programming so then ppl could look at the programs i write and figure out some of what i've done, and then they can ask about the rest and it'll be like ongoing learning

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts