0 Members and 2 Guests are viewing this topic.
I have 2 questions:How would I copy an arbitrary number of programs to one giant program?How would I read from a BASIC string variable?Thanks in advance
GetCalc("Str1")→P
:GetCalc("Str1")→P
:[]→GDB0:.Name of program:"prgm":[]→GDB1:.Start of characters in name of program:det(9):0→N:.N is the Nth program name in the string, starting with 0:0→C:Repeat {N*8+P+C}-175:.175 is the token code for "?":If {N*8+P+C}-20:.20 is the token code for " ":{N*8+P+C}→{GDB1+C}:End:C+1→C:End:0→{GDB1+C}
:GetCalc(GDB0)→Q
..AXE LIBRARY: MERGE.<DESCRIPTION>.This routine will merge multiple BASIC programs listed in an OS string into one program.Author: Runer112.Date: 10/24/10.Insert style: Inline.Parser version designed for: 0.4.5.Size as of version 0.4.5: 342 bytes.<INPUTS>.Str0M1: Name of OS string containing program names .Example format of data in OS string: "prgmPRGMNAMEprgmAprgmTEST".Str0M2: Output program name.<OUTPUTS>.Returns: 0 if failed, non-0 otherwise.A program, the name of which is determined by Str0M2.<DESTROYS>.Last 24 bytes of saveSScreen (last 24 bytes of L₁ as of 10/24/10).<ROUTINE>.Temporary program name storage (last 10 bytes of saveSScreen)ᴇ05→{ᴇ89EC-10}rFill(ᴇ89EC-9,8).{ᴇ89EC-12}r = merge loop iteration/pointer to merged program, {ᴇ89EC-14}r = total length of merged program in first iteration, current position in merged program in second iteration0→{ᴇ89EC-12}r→{ᴇ89EC-14}r.Merge loopLbl 0ML.Check that OS string exists, {ᴇ89EC-16}r = pointer to string, {ᴇ89EC-18}r = current position in stringIf GetCalc(Str0M1)→{ᴇ89EC-16}r→{ᴇ89EC-18}r .Repeat while position is not outside of string While sub(0MC) .{ᴇ89EC-20}r = current offset in temporary program name 0→{ᴇ89EC-20}r .Repeat until current token = prgm (0x5F) While {{{ᴇ89EC-18}r+1→{ᴇ89EC-18}r}→{{ᴇ89EC-20}r+1→{ᴇ89EC-20}r+ᴇ89EC-10}}-ᴇ5F .If position is outside of string !If sub(0MC) .Break Goto 0MD End End .Done copying name Lbl 0MD .Replace last byte with 0 0→{{ᴇ89EC-20}r+ᴇ89EC-10}r .Check that program to copy exists, {ᴇ89EC-20}r = pointer to program, {ᴇ89EC-22}r = length of program If {GetCalc(ᴇ89EC-10)→{ᴇ89EC-20}r-2}r→{ᴇ89EC-22}r .If second iteration If {ᴇ89EC-12}r .Copy program to merged program conj({ᴇ89EC-20}r,{ᴇ89EC-14}r,{ᴇ89EC-22}r) .If not last program to copy, {ᴇ89EC-24}r = backup of length of merged program If {ᴇ89EC-12}r+{ᴇ89EC-24}r-sub(0MM) .Append new line token ᴇ3F→{sub(0MM)-1} End End .Add length of current program (plus 1 for a new line token) to length of merged program sub(0MM)→{ᴇ89EC-14}r End End .If first iteration !If {ᴇ89EC-12}r .Attempt to create merged program and increase iteration count !If GetCalc(Str0M2,{ᴇ89EC-14}r→{ᴇ89EC-24}r-1)→{ᴇ89EC-12}r→{ᴇ89EC-14}r→{ᴇ89EC-12}r .Program creation failed, go to end Goto 0ME End Goto 0ML EndEnd.Go to endGoto 0ME.Merge position checkLbl 0MC {{ᴇ89EC-16}r-2}r+{ᴇ89EC-16}r-{ᴇ89EC-18}rReturn.Merge mathLbl 0MM {ᴇ89EC-14}r+{ᴇ89EC-22}r+1Return.Merge endLbl 0ME