Posted: Sun Jan 4, 1987 9:04 PM PST Msg: OGIH-2513-2776 From: CHHU To: CHHU Subj: Mike <- [-D re ALLREMS Wow, listing ALL the lines that CONTAIN a remark is a lot harder than just listing the lines that START with a REM or !. Matter of fact, I gave up trying to do it on the token level, and blush to offer the following silly way of doing it. To tell the truth, now that we have the FIND command, it is a snap to find the REMS: just type FIND " ! " or FIND " REM ". But this is essentiall y what the following rotuine does, for a whole program all at once. The peeking is still necessary to figure out the line numbers so that LIST$ knows which lines to try. Unfortunately, if a line contains a string that contains " REM " or " ! ", then that line will be mistakenly identified as a line that contains a remark. I can't figure out a way around this. Doing it the token way (like the previous LISTREMS) is foiled by the oddball tokenization of "!" remarks that are not preceded by an "@", e.g. 10 BEEP 440 ! noise. There is no easy way to tell where the BEEP command ends, without going to the BEEP parser, at least none that I can think of. (The statement length byte in this type of line includes both the BEEP and the remark. Yucko.) 1 ! ALLREMS -- lists all the lines in a BASIC file that contain a remark. 2 ! by Joseph K. Horn [13] 4 Jan 1987 3 ! Requires BASICLEX for the LIST$ function. 10 INPUT "Filename? ";F$ 20 A=HTD(ADDR$(F$))+49 @ E=A+PEEK(A-17,5)-17 30 IF RPEEK$(A-33,4)#"E214" THEN END 40 IF A=E THEN END 50 L=VAL(RPEEK$(A,4)) 60 IF POS(" "&LIST$(L,F$)," ! ") OR POS(" "&LIST$(L,F$)," REM ") THEN PRINT L 70 A=A+2 80 A=A+PEEK(A+2,2)+2 @ IF PEEK(A)=4 THEN 80 ELSE A=A+2 @ GOTO 40 Whoops; it doesn't LIST the lines that contain a remark; it prints a list of their line NUMBERS. If you want the lines too, modify the end of line 60: 60 IF POS ... THEN PRINT L;LIST$(L,F$) Unlike the original LISTREMS, which ran in a flash and then ended, this routine is actually searching for remarks, and so it can take a long time to run if the file is big. For example, running it on EDTEXT in the Assembler ROM takes half of forever... I'm still waiting... TWO MINUTES! Whereas FIND " REM " takes onl y 13 seconds. By the way, the seemingly silly repetition of LIST$ in line 60 is vital; due to a bug in LIST$, setting a string variable equal to LIST$ can trash memory. That's why DOTLIST in the Chronicle used the CHARSET$ to store LIST$. Such odd measures are necessary when dealing with buggy software! Joseph K. Horn [-D