On Apr 24, 2007, at 11:33 PM, Brian Heibert wrote: > I am re-creating BH-Basic > > I got this in the interpreter > My problem is that if you type > PRINT the text you want to print > Currently it also displays the NOTEALERT from the NOTEALERT command > below > Any help appreciated. Oh and I did one thing myself I searched > the archives to come up with the code to interpret commands below > > Local FN InitRuntime ( efID as long ) > dim as handle efH > dim as long i, numLines > dim as str255 lineStr > > // Obtain handle to selected edit field > efH = TeHandle( efID ) > > // Test for valid handle > long if ( efH != 0 ) > numLines = efH..teNLines% > // Test to see if EF contains any lines > long if ( numLines > 0 ) > for i = 1 to numLines > > > linestr = edit$(efID, i ) ' get the complete instruction as before > > ' ------- add these three lines ---------- > linestr2$ = linestr + " " ' ensure there's at least 1 space. > positionOfSpace = INSTR( 1, linestr2$, " " ) > keyWord$ = UCASE$( LEFT$( linestr2$, positionOfSpace - 1 ) ) > restOfCommand$ = MID$( lineStr, positionOfSpace + 1 ) > > SELECT CASE keyword$ = "NOTEALERT" > CALL PARAMTEXT (restOfCommand$, "", "", "") > butnPressed = FN NOTEALERT (129,0) > END SELECT > > SELECT CASE keyword$ = "PRINT" > WINDOW #_Output > PRINT restofCommand$ > END SELECT > // Do your stuff with each line here > next i > xelse > // Return error if EF has no lines to parse > numLines = -1 > end if > xelse > // Return error if EF is not valid > numLines = -1 > end if > > end fn = numLines > > -- Hi Brian H, As Brian S mentioned, it is STRONGLY recommended that you use DIM to declare each variable that is used within your function. And also as he hinted at, you needed to research, study, and learn how the various instructions work in FB. In particular, check the HELP files for the SELECT / CASE instructions: There are 2 syntax ways of using CASE but you have sort of combined those (with hard to predict results. (And SELECT in FB is slightly different than SELECT in RB, so don't assume anything - always check.) To get you started, here is one way to test the keyword and perform various actions... '-------------------------------------------------- SELECT keyword$ CASE "NOTEALERT" CALL PARAMTEXT (restOfCommand$, "", "", "") butnPressed = FN NOTEALERT (129,0) CASE "PRINT" WINDOW #_Output PRINT restofCommand$ CASE "ETC..." // do whatever is needed for each command END SELECT '-------------------------------------------------- Note that in your actions for PRINT, you are changing windows to show the output; don't forget to change back to your editor window so that the "linestr = edit$(efID, i )" instruction can access the correct edit field in that window. One final tip: You mentioned you found this in the archives. Keep searching there to find the many stages to the interpreter that you asked about and got detailed help with before. Several times I recall. Study the instructions and logic there. Now, 2 years later, you hopefully are wiser, more experienced, and able to follow it better. -Stu