line breaks with HP50g
|
08-30-2015, 07:30 AM
Post: #8
|
|||
|
|||
RE: line breaks with HP50g
(08-29-2015 09:18 AM)tigger Wrote: I guess you explained many steps in one sentence. Could I ask you to explain your solution more detailed? No problem; let's use your program to illustrate. Please actually do the following steps on your 50g (don't just read them). Step Zero puts your 50g in RPN mode with flag -117 set, which is the way all 50g's should be at all times. Please note: The following is a learning exercise. You will NOT have to go through all this every time you write a program! But please do this at least once, for the sake of learning some useful 50g concepts. 0. Turn on RPN mode (MODE CHOOSE RPN ENTER ENTER) and set flag -117 (-117 ALPHA S ALPHA F ENTER). 1. [right-shift] [×] ENTER (this puts an empty string on the stack). 2. [down-cursor] (this is the same as executing the EDITB command). 3. Key in your program, ending the lines wherever you wish by pressing the NEWLINE key which is [right-shift] [.] If you make a mistake or wish to change anything, just move the cursor around the screen using the cursor keys and edit it any way you wish. 4. When the program is all keyed in (it can be as wide and long as you wish), press the ENTER key to exit the editor. What you typed will be placed on the stack, not as a program object, but as a STRING object (as indicated by the double quotation marks around it). 5. Press the single-quote key ['], turn on ALPHA mode (press ALPHA twice), and type the name in which you wish to save the STRING form of your program, e.g. PROG.S (using .S to remind you that this is a "string" or "source code"). 6. Press ENTER. This puts the single-quoted name on level 1 of the stack, and raises your string to level 2. 7. Press STO. Both disappear, as the string gets stored into a variable with the name you typed. 8. Press VAR. You'll see the first 5 characters of your variable above the F1 key. Press F1 to recall the string to the stack. 9. Press [left-shift] [EVAL] [TYPE] [OBJ→]. This converts your string into an actual program object. If an error occurs, then you probably have one or more syntax errors, so press down-cursor to edit the string, fix the syntax errors, press ENTER to exit the editor, and try OBJ→ again. 10. Now save the program under a different name, e.g. 'PROG', the same way you saved the string version. It will appear above the F1 key (after pressing VAR), and the string version will move over to the F2 key. 11. Run the program by pressing its key in the VAR menu. Edit the program by editing the string version (complete with newlines wherever you prefer to place them) and then executing OBJ→ on it to convert the string object into a program object. In addition to strategic line breaks, you can even include comments in your programs if you use the above method! All you have to remember is that in RPL, comments begin with an "@" character. So, for example: "<< 1 2 + @ This adds two numbers 3 4 * @ and this multiplies two numbers / @ and that divides the sum by the product >>" is a string with line breaks AND comments. When OBJ→ is executed on that string, the following program is produced: << 1 2 + 3 4 * / >> Cool, huh? Hope that helps. Feel free to request clarification or ask further questions. Warning: Learning the 50g is an immense undertaking, so be patient with yourself, and try lots of things to see what happens. That's always a good way to learn. <0|ɸ|0> -Joe- |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
line breaks with HP50g - tigger - 08-25-2015, 05:19 PM
RE: Paragraphs - Allen - 08-28-2015, 02:03 AM
RE: Paragraphs - tigger - 08-28-2015, 05:24 PM
RE: Paragraphs - Joe Horn - 08-28-2015, 08:04 PM
RE: Paragraphs - Allen - 08-28-2015, 10:41 PM
RE: line breaks with HP50g - tigger - 08-29-2015, 09:39 AM
RE: line breaks with HP50g - tigger - 08-29-2015, 09:18 AM
RE: line breaks with HP50g - Joe Horn - 08-30-2015 07:30 AM
RE: line breaks with HP50g - tigger - 08-30-2015, 11:46 AM
RE: line breaks with HP50g - Joe Horn - 08-30-2015, 12:48 PM
|
User(s) browsing this thread: 1 Guest(s)