senior_falcon Posted October 29, 2019 Share Posted October 29, 2019 One thing occurred to me as a possibility: Parse the input line, convert to XB tokens and use them to create a new XB line. For example 10 INPUT FUNCTION$ 20 code to parse and tokenize the line and plug the tokens into line 100 ! need more than 1 line for this 30 RUN 40 40 rem actual start of the program 100 REM XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX After conversion, line 100 becomes y=cos(3*X)+3*x^2 and the XB program then knows what to do with it. 3 1 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted November 1, 2019 Author Share Posted November 1, 2019 Hmm.... anyone else here who wants to share his ideas to help the others? ? 1 Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted November 1, 2019 Share Posted November 1, 2019 I will post a short example of what I am thinking of. 1 1 Quote Link to comment Share on other sites More sharing options...
Asmusr Posted November 1, 2019 Share Posted November 1, 2019 20 minutes ago, senior_falcon said: I will post a short example of what I am thinking of. Self-modifying code, the unholy grail, the source of all evil. Imagine if we could do that in modern languages. I mean, how would we run the unit tests? 1 1 Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted November 2, 2019 Share Posted November 2, 2019 Here is a simple example that shows how to modify an existing XB line with a string that has been entered. Here, this only works with a variable and the operators + - * / The main point of this is to show that line 10 can be modified by the program and then used normally by the program. Here's how the program works: 1 - inputs the function. You can type in X*X*X or X*X-X or anything else using (only) the operators + - * /. Do not use constants i.e. X*X+2*X 2 - goes to a sub that modifies line 10. When done it runs the program starting at line 10 10 - as written, this must be in the third line. this DEF is modified by the subroutine in line 100. The lengthy comment is to make it a long line so that your function can fit. 20 - print out some numbers showing that it actually works 110-140 - look through the input string and replace + with CHRS(193); replace - with 194; replace * with 195; replace / with 196. This code could be much tighter. 150 - adds a remark to the end of the string and now A$ has been converted into XB tokens. 200 - PEEK >8332 to find beginning of line number table. Take that address and subtract 9. This points to the pointer to the code in the third line. PEEK that address. 3 bytes after that address is the X in line 10. 210 - copy A$ into the DEF statement in line 10. 220 - return. You can list the program and see that line 10 has been changed. This simple start should be enhanced so it can handle numeric constants, trig functions, exponentiation, etc. You can use the debugger in Classic99 to see how an XB line is tokenized. Type in a line 1 and look at CPU ram starting at >FF00. Somewhere near the bottom you will see 00 01 FF ??, a length byte, and the code. Remember that the debugger uses hexadecimal and XB likes decimal, so there is some conversion involved. Once you have it figured out, modify the program so the missing link or similar plotting program can actually do the plotting. 1 INPUT "Y=":A$ 2 GOSUB 100 :: RUN 10 10 DEF Y=X!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 20 FOR X=-3 TO 3 STEP .25 :: PRINT X,Y :: NEXT X 30 END 100 !CREATE BASIC LINE 110 P=POS(A$,"+",1):: IF P<>0 THEN A$=SEG$(A$,1,P-1)&CHR$(193)&SEG$(A$,P+1,255):: GOTO 110 120 P=POS(A$,"-",1):: IF P<>0 THEN A$=SEG$(A$,1,P-1)&CHR$(194)&SEG$(A$,P+1,255):: GOTO 120 130 P=POS(A$,"*",1):: IF P<>0 THEN A$=SEG$(A$,1,P-1)&CHR$(195)&SEG$(A$,P+1,255):: GOTO 130 140 P=POS(A$,"/",1):: IF P<>0 THEN A$=SEG$(A$,1,P-1)&CHR$(196)&SEG$(A$,P+1,255):: GOTO 140 150 A$=A$&CHR$(131) 200 CALL PEEK(-31950,M,L):: CALL PEEK(M*256+L-65536-9,M,L):: ADDRESS=M*256+L+2-65536 210 FOR I=1 TO LEN(A$):: CALL LOAD(ADDRESS+I,ASC(SEG$(A$,I,1))):: NEXT I 220 RETURN 3 2 1 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted November 2, 2019 Author Share Posted November 2, 2019 (edited) 7 hours ago, senior_falcon said: Here is a simple example that shows how to modify an existing XB line with a string that has been entered. Here, this only works with a variable and the operators + - * / The main point of this is to show that line 10 can be modified by the program and then used normally by the program. Here's how the program works: 1 - inputs the function. You can type in X*X*X or X*X-X or anything else using (only) the operators + - * /. Do not use constants i.e. X*X+2*X 2 - goes to a sub that modifies line 10. When done it runs the program starting at line 10 10 - as written, this must be in the third line. this DEF is modified by the subroutine in line 100. The lengthy comment is to make it a long line so that your function can fit. 20 - print out some numbers showing that it actually works 110-140 - look through the input string and replace + with CHRS(193); replace - with 194; replace * with 195; replace / with 196. This code could be much tighter. 150 - adds a remark to the end of the string and now A$ has been converted into XB tokens. 200 - PEEK >8332 to find beginning of line number table. Take that address and subtract 9. This points to the pointer to the code in the third line. PEEK that address. 3 bytes after that address is the X in line 10. 210 - copy A$ into the DEF statement in line 10. 220 - return. You can list the program and see that line 10 has been changed. This simple start should be enhanced so it can handle numeric constants, trig functions, exponentiation, etc. You can use the debugger in Classic99 to see how an XB line is tokenized. Type in a line 1 and look at CPU ram starting at >FF00. Somewhere near the bottom you will see 00 01 FF ??, a length byte, and the code. Remember that the debugger uses hexadecimal and XB likes decimal, so there is some conversion involved. Once you have it figured out, modify the program so the missing link or similar plotting program can actually do the plotting. 1 INPUT "Y=":A$ 2 GOSUB 100 :: RUN 10 10 DEF Y=X!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 20 FOR X=-3 TO 3 STEP .25 :: PRINT X,Y :: NEXT X 30 END 100 !CREATE BASIC LINE 110 P=POS(A$,"+",1):: IF P<>0 THEN A$=SEG$(A$,1,P-1)&CHR$(193)&SEG$(A$,P+1,255):: GOTO 110 120 P=POS(A$,"-",1):: IF P<>0 THEN A$=SEG$(A$,1,P-1)&CHR$(194)&SEG$(A$,P+1,255):: GOTO 120 130 P=POS(A$,"*",1):: IF P<>0 THEN A$=SEG$(A$,1,P-1)&CHR$(195)&SEG$(A$,P+1,255):: GOTO 130 140 P=POS(A$,"/",1):: IF P<>0 THEN A$=SEG$(A$,1,P-1)&CHR$(196)&SEG$(A$,P+1,255):: GOTO 140 150 A$=A$&CHR$(131) 200 CALL PEEK(-31950,M,L):: CALL PEEK(M*256+L-65536-9,M,L):: ADDRESS=M*256+L+2-65536 210 FOR I=1 TO LEN(A$):: CALL LOAD(ADDRESS+I,ASC(SEG$(A$,I,1))):: NEXT I 220 RETURN An outstandig teamwork senior_falcon. Danke! ? Edited November 2, 2019 by Sid1968 Quote Link to comment Share on other sites More sharing options...
RXB Posted November 2, 2019 Share Posted November 2, 2019 In XB GPL code is a routine called EXEC that executes a line independently. [0609] *********************************************************** [0610] * START EXECUTION OF A PROGRAM OR STATEMENT [0611] * DATA: [0612] * RAM(START) points into line number table at the [0613] * first line to execute [0614] * @PGMFLG contains >FF if executing a program or zero [0615] * if imperative statement [0616] *********************************************************** [0617] A09C 8E,44 EXEC CZ @PRGFLG If program [0618] A09E 60,AE BS GA0AE [0619] A0A0 BD,2E,A3 DST V@START,@EXTRAM Line to start execution at A0A3 72 [0620] A0A4 95,2E DINCT @EXTRAM Pointer to text pointer [0621] A0A6 06,A2,8D CALL INTRND Initialize random number [0622] A0A9 BE,7F,03 EXEC1 ST X2,@XPT Initialize screen display [0623] A0AC 40,B2 BR GA0B2 [0624] A0AE BF,2C,08 GA0AE DST CRNBUF,@PGMPTR Executing out of crunch buffe A0B1 20 [0625] A0B2 BF,26,A0 GA0B2 DST EXEC20,@RTNG Address of return from ALC 99/4 GPL-ASSEMBLER (Pass 3) correct PAGE 0011 EQUATES EXEC-359 A0B5 BC [0626] A0B6 BF,28,A1 DST NUDTB,@NUDTAB NUD table address for ALC A0B9 47 [0627] A0BA 0F,76 XML EXECG Execute XB [0628] A0BC 8A,23 EXEC20 CASE @ERRCOD+1 Check type of return [0629] A0BE 40,DF BR EXECND 0 - NORMAL END [0630] A0C0 41,1A BR EXECBK 1 - BREAKPOINT [0631] A0C2 40,ED BR EXECTR 2 - TRACE [0632] A0C4 48,AB BR ERORZ 3 - ERROR [0633] A0C6 40,D4 BR WARNGZ 4 - WARNING [0634] A0C8 41,DA BR ONERR 5 - ON ERROR [0635] A0CA 47,17 BR UDF 6 - FUNCTION [0636] A0CC 42,18 BR ONBRK 7 - ON BREAK [0637] A0CE 44,38 BR CONCAT 8 - CONCATENATE STRINGS "&" [0638] A0D0 41,AA BR ONWARN 9 - ON WARNING [0639] A0D2 42,2F BR GPLCAL A - CALL STATEMENT [0640] A0D4 C6,73,B0 WARNGZ CH >B0,@SUBSTK [0641] A0D7 6D,CA BS ERRSO [0642] * Stack overflow [0643] * ALLOW ROOM ON STACK FOR WARNING CALLS [0644] A0D9 06,6A,82 WRNN01 CALL WARNZZ ONLY WARNING MSG FROM XB SUPPORT [0645] A0DC 02 BYTE 2 * NUMERIC OVERFLOW [0646] A0DD 41,16 BR CLRRTN Clear ERRCOD and return [0647] * NORMAL END OF EXECUTION [0648] A0DF 8E,44 EXECND CZ @PRGFLG If imperative mode [0649] A0E1 40,E9 BR ERRRDY [0650] A0E3 06,60,1C CALL CHRTAB Load the default character se [0651] A0E6 05,63,DD B TOPL15 Return to top-level [0652] A0E9 06,6A,84 ERRRDY CALL ERRZZ Display * READY * [0653] A0EC 00 BYTE 0 [0654] * TRACE-MODE turned on - display line number [0655] A0ED 86,20 EXECTR CLR @VARW Clear upper address byte [0656] A0EF BC,21,7F ST @XPT,@VARW+1 Get current x-pointer [0657] A0F2 A3,20,02 DADD NLNADD-3,@VARW Make a valid screen address A0F5 DF [0658] A0F6 C7,20,02 DCH NLNADD+22,@VARW If might go off screen A0F9 F8 [0659] A0FA 41,02 BR GA102 [0660] A0FC 0F,83 XML SCROLL SCROLL to next line [0661] A0FE BF,20,02 DST NLNADD,@VARW Re-initialize screen address A101 E2 [0662] A102 BE,B0,20 GA102 ST LESS+OFFSET,V*VARW Display open bracket "(" A105 9C [0663] A106 91,20 DINC @VARW Increment screen address [0664] A108 06,A8,8A CALL ASC Convert line # into ASCII [0665] A10B BE,B0,20 ST GREAT+OFFSET,V*VARW Display close bracket ")" A10E 9E [0666] A10F A7,20,02 DSUB NLNADD-4,@VARW Update the x-pointer A112 DE [0667] A113 BC,7F,21 ST @VARW+1,@XPT [0668] A116 87,22 CLRRTN DCLR @ERRCOD Clear the return vector [0669] A118 0F,82 XML RTNB Return to ALC [0670] * BREAKPOINT OR BREAK-KEY RECIEVED [0671] A11A 8E,44 EXECBK CZ @PRGFLG If break or program [0672] A11C 61,43 BS ERRBRK [0673] A11E BD,52,2E DST @EXTRAM,@FAC8 @FAC8 : Source addr in ERAM [0674] A121 97,52 DDECT @FAC8 Point to the line # [0675] A123 06,A7,0C CALL UBSUB1 Reset the breakpoint [0676] A126 03 SCAN Get break key out of queue [0677] A127 BD,A3,82 EXEC6C DST @PGMPTR,V@SPGMPT Save text pointer A12A 2C [0678] A12B BD,A3,86 EXEC6D DST @EXTRAM,V@SEXTRM Save line number table pointe A12E 2E [0679] A12F BD,A3,88 DST @VSPTR,V@SAVEVP Save value stack pointer 99/4 GPL-ASSEMBLER (Pass 3) correct PAGE 0012 EQUATES EXEC-359 A132 6E [0680] A133 BD,A3,84 DST @BUFLEV,V@SBUFLV Save crunch buffer level A136 46 [0681] A137 BD,A3,96 DST @LSUBP,V@SLSUBP Save last subprogram on stack A13A 48 [0682] A13B BC,A3,98 ST @FLAG,V@SFLAG Save FLAG for continue A13E 45 [0683] A13F B2,A3,98 AND >63,V@SFLAG Only warning and break bits A142 63 [0684] A143 06,6A,84 ERRBRK CALL ERRZZ * BREAKPOINT [0685] A146 01 BYTE 1 [0686] *********************************************************** [0687] * NUD / STATEMENT BRANCH TABLE [0688] *********************************************************** [0689] A147 41,89 NUDTB BR RECX 'RECORD' 0 [0690] A149 46,8B BR NBREAK 'BREAK' 0 [0691] A14B 46,9D BR NUNBRK 'UNBREAK' 0 [0692] A14D 46,81 BR NTRACE 'TRACE' 0 [0693] A14F 46,86 BR NUNTRC 'UNTRACE' 0 [0694] A151 41,8C BR NREADX 'READ' 0 [0695] A153 41,8F BR PRINTX 'PRINT' 0 [0696] A155 41,86 BR SZRUNX 'RUN' 0 [0697] A157 41,A7 BR LINPUX Reserved for LINPUT 1 [0698] A159 41,92 BR RESTOX 'RESTORE' 1 [0699] A15B 43,7F BR NRNDMZ 'RANDOMIZE' 1 [0700] A15D 41,95 BR INPUTX 'INPUT' 1 [0701] A15F 41,98 BR OPENX 'OPEN' 1 [0702] A161 41,9B BR CLOSEX 'CLOSE' 1 [0703] A163 42,48 BR NPI 'PI' 1 [0704] A165 42,58 BR NMAX 'MAX' 1 [0705] A167 42,65 BR NMIN 'MIN' 2 [0706] A169 46,28 BR RPTZ01 'RPT$' 2 [0707] A16B 41,9E BR ACCEPX 'ACCEPT' 2 [0708] A16D 41,83 BR EOFX 'EOF' 2 [0709] A16F 45,1A BR ASC01 'ASC' 2 [0710] A171 45,BD BR POS01 'POS' 2 [0711] A173 45,55 BR VAL01 'VAL' 2 [0712] A175 45,2B BR STRZ01 'STR$' 2 [0713] A177 44,90 BR SEGZ01 'SEG$' 3 [0714] A179 41,A4 BR DELETX 'DELETE' 3 [0715] A17B 41,A1 BR DISPLX 'DISPLAY' 3 [0716] A17D 44,F3 BR LEN01 'LEN' 3 [0717] A17F 44,FF BR CHRZ01 'CHR$' 3 [0718] *RXB PATCH CODE FOR BASIC RND REPLACEMENT *********** [0719] A181 42,AF BR NRND 'RND' 3 [0720] * The following are long branches to another GROM [0721] A183 05,80,1C EOFX B EOF [0722] A186 05,60,1E SZRUNX B SZRUN [0723] A189 05,80,22 RECX B REC [0724] A18C 05,80,0E NREADX B NREAD [0725] A18F 05,80,04 PRINTX B PRINT [0726] A192 05,80,0C RESTOX B RESTOR [0727] A195 05,80,06 INPUTX B INPUT [0728] A198 05,80,08 OPENX B OPEN [0729] A19B 05,80,0A CLOSEX B CLOSE [0730] A19E 05,80,1E ACCEPX B ACCEPT [0731] A1A1 05,80,00 DISPLX B DISPL1 [0732] A1A4 05,80,02 DELETX B DELET [0733] A1A7 05,80,30 LINPUX B LINPUT [0734] *********************************************************** [0735] * FLAGS USED IN EXECUTION MODE: this needs to be checked [0736] * @FLAG BIT RESET SET [0737] * 0 [0738] * 1 Warning PRINT PRINT off 99/4 GPL-ASSEMBLER (Pass 3) correct PAGE 0013 EQUATES EXEC-359 [0739] * 2 Warning NEXT STOP [0740] * 3 Not in UDF Executing a UDF [0741] * 4 TRACE mode Normal mode [0742] * 5 [0743] * 6 BREAK allowed BREAK not allowed [0744] * 7 No LST/EDT protect LIST/EDIT protected [0745] *********************************************************** [0746] * ON WARNING {NEXT | STOP | PRINT} [0747] * ON WARNING NEXT - Causes warning messages to be ignored [0748] * and execution to continue as if a [0749] * warning never occurred [0750] * ON WARNING STOP - Causes a warning to be treated as an [0751] * error - i.e. the message is displayed [0752] * and execution is halted [0753] * ON WARNING PRINT - Causes the default warning handling to [0754] * be in effect, i.e. any warning [0755] * messages are printed and execution [0756] * continues [0757] *********************************************************** [0758] A1AA 0F,79 ONWARN XML PGMCHR GET OPTION [0759] A1AC D6,42,9C CEQ PRINTZ,@CHAT If print [0760] A1AF 41,B7 BR GA1B7 [0761] A1B1 B2,45,F9 AND >F9,@FLAG Turn on print and contiue [0762] A1B4 05,A1,CF B ONWRN5 [0763] A1B7 D6,42,98 GA1B7 CEQ STOPZ,@CHAT [0764] A1BA 41,C4 BR GA1C4 [0765] A1BC B2,45,FD AND >FD,@FLAG Turn on print [0766] A1BF B6,45,04 OR >04,@FLAG Turn on stop [0767] A1C2 41,CF BR ONWRN5 [0768] A1C4 D6,42,96 GA1C4 CEQ NEXTZ,@CHAT * SYNTAX ERROR [0769] A1C7 4D,BA BR ERRSYN [0770] A1C9 B6,45,02 OR >02,@FLAG Turn off print [0771] A1CC B2,45,FB AND >FB,@FLAG Turn off stop [0772] A1CF 0F,79 ONWRN5 XML PGMCHR Check for EOS [0773] A1D1 06,6A,78 ONWRN7 CALL CHKEND Error if not EOS [0774] A1D4 4D,BA BR ERRSYN If not EOS [0775] A1D6 87,22 DCLR @ERRCOD [0776] A1D8 0F,75 XML CONT Continue [0777] *********************************************************** [0778] * ON ERROR {line number | STOP} [0779] * ON ERROR line number - causes the error routine to build [0780] * an error stack entry and pass [0781] * control to the line specified in [0782] * the most-recently executed [0783] * on-error-statement [0784] * ON ERROR STOP - causes the default error handling [0785] * conditions to be in effect. i.e. any [0786] * errors that occur cause execution to halt [0787] * an a message to be displayed [0788] *********************************************************** [0789] A1DA 0F,79 ONERR XML PGMCHR Get option [0790] A1DC D6,42,C9 CEQ LNZ,@CHAT If line # then find the line [0791] A1DF 42,0E BR GA20E [0792] A1E1 0F,79 XML PGMCHR Get upper byte [0793] A1E3 BC,4A,42 ST @CHAT,@FAC [0794] A1E6 0F,79 XML PGMCHR Get lower byte [0795] A1E8 BC,4B,42 ST @CHAT,@FAC1 [0796] A1EB BD,4C,32 DST @ENLN,@FAC2 [0797] A1EE A7,4C,00 DSUB 3,@FAC2 Pointing to 1st line # A1F1 03 [0798] * Consider both ERAM and RAM cases to get line # from the [0799] * line number table. Also reset the break bit. [0800] A1F2 06,80,2E ONERR2 CALL GRSUB3 Get 2 bytes from either RAM/E [0801] A1F5 4C BYTE FAC2 * FAC2 has the address 99/4 GPL-ASSEMBLER (Pass 3) correct PAGE 0014 EQUATES EXEC-359 [0802] A1F6 D5,4A,58 DCEQ @EEE1,@FAC If found [0803] A1F9 62,06 BS ONERR4 [0804] A1FB C5,4C,30 DCH @STLN,@FAC2 Not found [0805] A1FE 4D,E6 BR ERRLNF [0806] A200 A7,4C,00 DSUB 4,@FAC2 Goto next line A203 04 [0807] A204 41,F2 BR ONERR2 [0808] A206 95,4C ONERR4 DINCT @FAC2 [0809] A208 BD,A3,8A DST @FAC2,V@ERRLN A20B 4C [0810] A20C 42,16 BR GA216 [0811] A20E D6,42,98 GA20E CEQ STOPZ,@CHAT * SYNTAX ERROR [0812] A211 4D,BA BR ERRSYN [0813] A213 87,A3,8A DCLR V@ERRLN Back to default error handlin [0814] A216 41,CF GA216 BR ONWRN5 Finish up same as ON WARNING [0815] *********************************************************** [0816] * ON BREAK {NEXT | STOP} [0817] * ON BREAK NEXT - Causes any breakpoints which have been [0818] * set on statements to be ignored when the [0819] * statement is encountered and also masks [0820] * the shift-C key so that it is ignored [0821] * ON BREAK STOP - Causes the default break handling to be [0822] * in force., i.e. execution is halted and [0823] * the BREAKPOINT message is displayed on [0824] * the screen [0825] *********************************************************** [0826] A218 0F,79 ONBRK XML PGMCHR Get next char to find option [0827] A21A D6,42,98 CEQ STOPZ,@CHAT If stop option specified [0828] A21D 42,25 BR GA225 [0829] A21F B2,45,BF AND >BF,@FLAG break allowed [0830] A222 05,A2,2D B GA22D Don't change this to BR GA22D [0831] A225 D6,42,96 GA225 CEQ NEXTZ,@CHAT If next option number [0832] A228 4D,BA BR ERRSYN specified then syntax error [0833] A22A B6,45,40 OR >40,@FLAG If next option specified then [0834] * break NOT allowed [0835] A22D 41,CF GA22D BR ONWRN5 Finish up same as ON WARNING [0836] *********************************************************** [0837] * GPLCAL - If a call is made to a subprogram that does not [0838] * not exist either in the BASIC program itself or in the [0839] * internal GPL subprogram list then one final attempt is [0840] * made to find the subprogram at execution time by [0841] * searching for the subprogram in the console or a [0842] * peripheral. If not found there, then a [0843] * *SUBPROGRAM NOT FOUND error occurs [0844] * [0845] * Input: the subprogram name is in the FAC and the length [0846] * of the name is in FAC15 [0847] *********************************************************** [0848] A22F 8E,80,89 GPLCAL CZ @RAMFLG Can't try if CPU program [0849] A232 4D,F6 BR ERRSNF [0850] A234 E7,59,00 DSRL 8,@FAC15 Make name length a double A237 08 [0851] A238 A5,2C,59 DSUB @FAC15,@PGMPTR Point back at name [0852] A23B 93,2C DDEC @PGMPTR Point at name length [0853] A23D BD,56,2C DST @PGMPTR,@FAC12 Set pointer to name [0854] A240 06,00,10 CALL LINK Issue 'Call Program Link' [0855] A243 0A BYTE 10 * Search subprogram lists [0856] A244 41,D1 BR ONWRN7 If all ok, check-end and rtn [0857] A246 4D,F6 BR ERRSNF If not found, error [0858] *********************************************************** 1 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted November 2, 2019 Author Share Posted November 2, 2019 (edited) 1 hour ago, RXB said: In XB GPL code is a routine called EXEC that executes a line independently. Hey Rich is back.. Thank you mate! ? Can you please explain the NON-Pros the advantage of this EXEC-Routine for our second Challenge more detailed? Cheers Sid Edited November 2, 2019 by Sid1968 Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted November 2, 2019 Share Posted November 2, 2019 1 hour ago, RXB said: In XB GPL code is a routine called EXEC that executes a line independently. Executing the line is the least of your problems. First you have to create one from a human readable string. For example: X^3+2*X^2+3*COS(X) This is not an executable program line in XB and so must be converted in to XB code. Once the string is converted into proper XB code it must be placed where it can be executed. After that has happened I would guess that RUN 10 would work as well as EXEC. 1 1 Quote Link to comment Share on other sites More sharing options...
RXB Posted November 2, 2019 Share Posted November 2, 2019 1 hour ago, senior_falcon said: Executing the line is the least of your problems. First you have to create one from a human readable string. For example: X^3+2*X^2+3*COS(X) This is not an executable program line in XB and so must be converted in to XB code. Once the string is converted into proper XB code it must be placed where it can be executed. After that has happened I would guess that RUN 10 would work as well as EXEC. Yea conversion happens in Edit mode and the only thing I have ever come up with to use Edit Mode and Program mode at same time is RXB subcommand: CALL USER("DSK#.FILENAME") This text file has to end each command with a CR (Enter key) so using TI Writer is best way to go or use a XB program I wrote: 100 OPEN #1:"DSK2.USER-DEMO",INPUT 110 OPEN #2:"DSK2.BATCH",OUTPUT 120 LINPUT #1:Z$ 130 IF LEN(Z$)=80 THEN X$=X$&Z$ :: GOTO 120 140 IF LEN(Z$)<80 THEN PRINT #2:X$&Z$&CHR$(13) 150 X$,Z$="" :: GOTO 120 This takes a DV 80 Text file named USER-DEMO and turns it into a DV 80 Text TI Writer file named BATCH. Now the advantage is the lines can be any length up to what fills the Crunch Buffer which sadly limits the size of a program line to 160. Of Course 254 would be the TI99/4A limit for good reasons, but the Crunch Buffer is smaller for unknown reasons. the Crunch Buffer is only 160 token in size? (Maybe for MERGE Format 163 tokens in size.) The Edit Recall Buffer is only 150 bytes long? (Have to admit this is the most stupid set up possible!) The Edit Recall buffer should be 254 characters long, but I digress stupid is as stupid does. (Forest Gump's mom) 1 1 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted November 3, 2019 Author Share Posted November 3, 2019 Thank you Rich! I have another idea, but dont know if it will be target-aimed. Mechatronic Extended Basic II Plus offers the Axis function (Description on Page 63 in the manual. Examples on Page 43, 47, 63, 64 and 77). We already know that. Could it be, that Mechatronic Extended Basic II Plus found a solution for the actual question on how to solve the functionprompt (is there a better word), too? Who knows... Cheers Sid 1 Quote Link to comment Share on other sites More sharing options...
HOME AUTOMATION Posted November 3, 2019 Share Posted November 3, 2019 On 11/1/2019 at 9:52 PM, senior_falcon said: 1 INPUT "Y=":A$ 2 GOSUB 100 :: RUN 10 10 DEF Y=X!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 20 FOR X=-3 TO 3 STEP .25 :: PRINT X,Y :: NEXT X 30 END 100 !CREATE BASIC LINE 110 P=POS(A$,"+",1):: IF P<>0 THEN A$=SEG$(A$,1,P-1)&CHR$(193)&SEG$(A$,P+1,255):: GOTO 110 120 P=POS(A$,"-",1):: IF P<>0 THEN A$=SEG$(A$,1,P-1)&CHR$(194)&SEG$(A$,P+1,255):: GOTO 120 130 P=POS(A$,"*",1):: IF P<>0 THEN A$=SEG$(A$,1,P-1)&CHR$(195)&SEG$(A$,P+1,255):: GOTO 130 140 P=POS(A$,"/",1):: IF P<>0 THEN A$=SEG$(A$,1,P-1)&CHR$(196)&SEG$(A$,P+1,255):: GOTO 140 150 A$=A$&CHR$(131) 200 CALL PEEK(-31950,M,L):: CALL PEEK(M*256+L-65536-9,M,L):: ADDRESS=M*256+L+2-65536 210 FOR I=1 TO LEN(A$):: CALL LOAD(ADDRESS+I,ASC(SEG$(A$,I,1))):: NEXT I 220 RETURN I liked this FIRST... But may understand it last! Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted November 4, 2019 Author Share Posted November 4, 2019 On 11/3/2019 at 10:34 AM, HOME AUTOMATION said: I liked this FIRST... But may understand it last! In this case a question to the author could be a good idea. Maybe he will answer it. Quote Link to comment Share on other sites More sharing options...
apersson850 Posted November 4, 2019 Share Posted November 4, 2019 Print a prompt for the user to enter the equation to plot as line number 10, then give the command RUN. After that, exit the program and just wait until it's RUN again. 1 Quote Link to comment Share on other sites More sharing options...
HOME AUTOMATION Posted November 4, 2019 Share Posted November 4, 2019 2 hours ago, Sid1968 said: In this case a question to the author could be a good idea. Maybe he will answer it. Au contraire, I recognize that the thoroughness of senior_falcon's provided description... will require my mind, be cleared and reloaded! 1 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted November 4, 2019 Author Share Posted November 4, 2019 (edited) 6 hours ago, HOME AUTOMATION said: will require my mind, be cleared and reloaded! So you will need to live much more healthy. Leave out all these fruits and vegetables and eat chocolate. So many vitamins are in it. To name one... the chocolatevitamin. Alternatively you could start to smoke, but i really dont know how many vitamins are in one cigarette. Did you ever noticed that there are no vitaminadvices on cigarettboxes?!? Edited November 4, 2019 by Sid1968 Quote Link to comment Share on other sites More sharing options...
HOME AUTOMATION Posted November 5, 2019 Share Posted November 5, 2019 I hereby nominate you for: SURGEON GENERAL. 1 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted November 6, 2019 Author Share Posted November 6, 2019 What an honor. Thank you. My first enacment would take care of the most urgent crisis of the US-Healthsystem and create many hundred of thousands free parking spaces for drunkards. ? Quote Link to comment Share on other sites More sharing options...
senior_falcon Posted November 6, 2019 Share Posted November 6, 2019 (edited) On 11/3/2019 at 4:34 AM, HOME AUTOMATION said: I liked this FIRST... But may understand it last! In this case a question to the author could be a good idea. Maybe he will answer it. ************************************************************************ Classic99 can be very helpful in understanding how XB programs are put together. Start with a "cold reset" and then select XB. There should not be a LOAD program in DSK1. Now you can enter an XB line. (edit) Use the debugger to inspect the line. >8330 and >8332 are pointers to the start and end of the line number table. Once you know that you can look at the actual XB program line, not what you see when you LIST it. Edited November 6, 2019 by senior_falcon 1 2 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted November 11, 2019 Author Share Posted November 11, 2019 (edited) CHALLENGE 2 - THE RESULTS: Ladies and Gentlemen, the timelimit of the second Challenge expired. Lets look at the task, the discussion and the results. The Task: Post #419 This challenge and those who comes build up on the Challenges before. 1. Colors: Background: WHITE AXIS: Black Function: BLUE 2. Integrate a prompt for the X-Range. 3. Integrate a prompt for the function. 4. Plot the function and the X-Range of Challenge 1. The Deadline is 11/10/2019. Post #422 The Program should ask: f(x)= Where the user can put in for example: cos(3x) + 3x^2 Then it should ask for the X-Range, and then plot the function. The user should decide what function in what X-Range should be plotted. The Discussion: ------------------ In light of the fact that this second challenge was really not easy, it was all the more surprising that a vivid discussion about a solution didnt happen. Only senior_falcon and Rich were really exterted himselfs to find a solution. Award Ceremony: ------------------- I like to thank senior_falcon and Rich, for the courage to face up this challenge. As it turned out, the realisation of a function prompt was (till today) a too difficult task for this community. Here are the results senior_falcon Rich (RXB) Since we have no results for this second challenge, it makes no sense to start a third challenge. Despite everything, we learned a lot. Thank you all. Sid ? Edited November 11, 2019 by Sid1968 Quote Link to comment Share on other sites More sharing options...
Tursi Posted November 11, 2019 Share Posted November 11, 2019 You probably have to give more back than pictures of food (amusing as that is) to get participation. There are no shortages of challenges out there, and a lot of us assumed that you would be participating, not just judging. In addition, you probably need to consider the difficulty of your challenges. To get maximum participation, you want to start with a simple challenge that a lot of people can do, and step it incrementally. Plotting a sine wave isn't bad, actually - even a beginner in TI BASIC could have plotted a sine wave using asterisks or the like. But then you made a very tight specific requirement for the plot, which is actually difficult to achieve on the TI platform. The only reason I played along is that I like playing with my old TI BASIC plot function. Even so, there are a few languages that can access bitmap and it's not too hard there, so you got a few bites. But then you moved on to writing a generic function parser - and THAT is a non-trivial task even for skilled programmers. I wasn't interested for two reasons: I've done one before and I know how much work it is, and the result would be unlikely to fit in the memory limitations of TI BASIC alongside my plot function (which is restricted to roughly 12k of RAM, even on an expanded system). (Although, the suggestion to just tell the user to enter it as a line of code and then run the program was pretty brilliant!) People need to be able to see the path to the finish line for this sort of thing. If challenge 2 had simply been to specify the ranges, that alone might have motivated some people. If it had been an incremental step towards the function parser, like selecting values for a fixed function, that might have worked. If you had provided any kind of reference, like pseudo-code, you might have been able to spark that input you were looking for. But even then... when the ultimate program was complete, I don't think very many people would have had a use for it. You need a target that's a little more appealing. I dunno, just my two bits. If you try again - see if you can have a suggested answer for each step to compare against what everyone else builds. That will help you understand the difficulty of the step before you propose it. 4 1 Quote Link to comment Share on other sites More sharing options...
apersson850 Posted November 11, 2019 Share Posted November 11, 2019 2 hours ago, Tursi said: (Although, the suggestion to just tell the user to enter it as a line of code and then run the program was pretty brilliant!) I thought it was the only realistic one, in this context. Didn't render any pizza, though. No, the task isn't too difficult for this community. As I've written some compilers, I know exactly how to do a recursive descent parser, for example. Including the code generation. But it's ridiculous to do in BASIC, when there are other options. So for BASIC, that suggestion I made works best. Other languages are available here, but to spend the effort to create a good program nobody will ever use, that doesn't make sense. All the less when it became obvious that you, Sid1968, had no interest whatsoever in learning anything yourself. Doing this because it has to be done is like work. This is a hobby. Here we learn together and create for fun. 2 Quote Link to comment Share on other sites More sharing options...
Sid1968 Posted November 11, 2019 Author Share Posted November 11, 2019 (edited) 5 hours ago, Tursi said: You probably have to give more back than pictures of food (amusing as that is) to get participation. You are talking about medals of honor, buddy... I wish you had that creativity in explaining why you didnt made it, in the discussion for the past two weeks. But... i have a big sense of humor and take it easy. This project is burried. I like you all and aspersson850, you too!!! Cheers Buddies! ? Edited November 11, 2019 by Sid1968 Quote Link to comment Share on other sites More sharing options...
apersson850 Posted November 11, 2019 Share Posted November 11, 2019 Nobody would ever have used it today. Back in the 80's, yes. But today you use Excel or Matlab or stuff like that, depending on how complex the task is. So the task has to be fun, because it's just for fun it would be done. If you're going to start more threads like this one, then next time, I hope you learned from this attempt that you need to participate, work and learn yourself too. Otherwise you'll not encourage people to do things. 1 Quote Link to comment Share on other sites More sharing options...
+Lee Stewart Posted November 12, 2019 Share Posted November 12, 2019 On 10/22/2019 at 6:16 AM, apersson850 said: In Forth, you can define words that evaluate the function. But the plot package has to access a function that's not yet defined. And can later be redefined any number of times. I've not used Forth enough to know the best way to do that. Can you have a pointer to a word, and run it like that? As you define words, they are packed in memory, one after another. Can you redefine a word, when more other words have been defined after it? How does it fit, if the new definition is longer? Generally speaking, you can only execute words that have been defined ahead of the definition that invokes them. You can, indeed, use pointers to words—typically, the cfa (code field address), which can be executed by the Forth inner (address) interpreter. You could certainly devise a scheme to pass the cfa of a word defined later to be executed after that later word is defined. You can also redefine words in that you can use the same name for a completely new definition, but only words after the new (re)definition will use the new definition. If you mean redefining the old word in place, you could contrive a way to do that, but, as you imply, enough room would need to be anticipated, which is easily done but, I think, a bit impractical. I think it would be better to design a generic plot routine that would accept a pointer to any new function entered into your function parser by the user. Of course, I may misunderstand your intent. In addition, the Forth TMS9900 Assembler allows you to use snippets of assembly code that can be tested immediately without needing to design an ALC testing harness—the Forth interpreter is that testing harness, but I digress.... ...lee 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.