AIHELP.txt|MICROWORLD BASIC MICROBEE DENSE REFERENCE|for AI use writing/checking programs, not human-formatted|rules grounded in real working code+official manuals, not guessed|CONF=confirmed-real UNCONF=seen-once-or-guessed,verify-before-relying-on VARNAMES{INT=singleletterA-Z only,nothingelse;REAL=letter+exactly1digit(A0 F1 M9);STR=letter+1digit+$(A1$ K1$ D0$);NEVER 2+letters(PX DX wrong);NEVER %;NEVER bareletterplus$(K$ wrong,use K1$);loopcounters/coords reuse same letters across different parts of a program,normal not sloppy;only26 int names total so budget carefully in big programs} DIM{DIM A(8)=INTarray 9elem 0..8;DIM A0(9)=REALarray 10elem0..9;multi:DIM A(9),B0(10);multidim ok:DIM A0(N,S,S);sizescanbe VARIABLES not just literals:DIM P1(A) CONF;STRINGarrays DIM'd AS REAL name(NO $ in DIM stmt):DIM F0(9) then F0$(1)="x" CORRECT / DIM F0$(9) WRONG} STRINGS{noMID$/LEFT$/RIGHT$/INKEY$ exist,CONF absent from manual+realtokentable+all15programs;SUBSTRING SYNTAX DOES EXIST(corrects earlier wrong belief that none exists):string$(;start,end)=chars start..end inclusive;string$(;k,k)=single char at k;string$(;start)=start to end,endoptional;semicolon REQUIRED,every real instance has it;assignable:Z0$=Z0$(;1,X-1)+A1$+Z0$(;X+1);chains onto array elems directly:I1$(E)(;1,1);indices can be exprs not just literals:Z0$(;LEN(Z0$),LEN(Z0$));realexample caseinsensitive-search idiom:FORL=1TOE:X=(ASC(S1$(;L,L))AND95):IFX>0THENLETU1$=U1$+CHR(X)ELSELETU1$=U1$+" ":NEXTL;altpattern for cell/mapdata=2Darray of small ints w/ IF/THEN dispatch to print char(AIPROG maze style),avoids strings entirely,also valid;CONFIRMED fns:CHR$(n)/CHR(n) BOTHvalid $optional;KEY$/KEY BOTHvalid $optional,NOparens/args,returns""ifnokeydown,nonblocking;STR$(n)->string;concat with + works normal} IFTHENELSE{THEN linenum(bare)=implicitGOTO;ELSE linenum(bare)=implicitGOTOtoo CONF;THEN omittable directly before GOTO:IFcondGOTOn valid CONF;ELSEIF chains real&work:IFa THENx ELSEIF b THENy ELSEIF c THENz CONF extensively(gol3 galactic);LETRULE(refined,important): only the FIRST stmt immediately after literal word THEN/ELSE needs explicit LET if it's an assignment,e.g. THEN LET L1(E)=L1(E)-8:U1(E)=0 <-2ndassign noLET needed,fine;usingPLAINCOLON instead of THEN needs ZERO LET anywhere on that line:IFcond:stmt1:stmt2 CONF(staking selector harry all confirm,multipleauthors,notatypo);simplest safe default=LET never wrong to add,only truly REQUIRED right after literal THEN/ELSE;relops < > = <= >= <>;logic NOT AND OR,precedence NOT>AND>OR,parens override;bool TRUE=-1 FALSE=0 not1/0} LOOPS{FORvar=e1 TOe2[STEPe3],defaultstep1,negative/fractional stepsok,intloopsfaster thanreal;NEXT[var];NEXT*var linenum = THE REAL "NEXT*"COMMAND,missed in v1 of this ref despite being asked for by name-exits the named FOR loop EARLY(as if its own NEXT triggered)AND jumps to linenum,one statement,CONFextensively(gol3 galactic bounce ACCANTS harry-harry uses it ~20x);realshape: loop body has IFTHEN NEXT*var dest ELSE... with plain NEXTvar at the bottom for normal fallthrough;GOSUBlinenum...RETURN std;VAR(v1,v2..)=first stmt of sub receiving GOSUB-passed values;GOSUB[e1,e2..]linenum=computed-gosub passing values into VARlist;GOTO/GOSUB targets CAN be computed exprs not just literals:GOTO INT(20000+(L1(E)*100)) CONF;ONintexpGOTOl1,l2,l3..;ONintexpGOSUBl1,l2..(1-based,0/overflow=fallthrough to next stmt);multistatement=coloned:R=0:B=0:T=0 CONFeverywhere;linenos plain no leadingzeros normal,range1-65534} DATAREAD{DATAe1,e2,..;READv1,v2,..;RESTORE[linenoOR EXPR]=resetpointer,exprconfirmed real:RESTORE220+Z CONF(harry);READ(lineno)var=reset pointer to that DATA stmt AND read in one go,CONF(ACCANTS:READ(L)M1$)} PRINT{,=zonespace(ZONEn setswidth1-16);;=nospace+suppresstrailingCRLF;\=forceextraCRLF,repeatable\\\\ ok;TAB(n)movestocol,argcanbeexpr;SPC(n)=always exactly n spaces regardless of position(diff fromTAB);FORMATSPECIFIERS confirmed real(not justmanual):[Iwidth exp]=int rightjust CONF PRINT[I4 X];[Fwidth.dec exp]=real fixeddecimals CONF PRINT[F8.1 A3];[Owidth exp]=exponential;[Aexp]=CHR$(exp)repeatedEXPtimes,CONF PRINT[A18 42]prints"*"x18(examplereused expmeanscount not the char code arg order is [A COUNT charcode])} CURSCLS{CURSn=linear0-1023;CURScol,row=col1-64 row1-16;nospaceneededafterCURS,CURS1,1valid;CLS=clearscreen+homecursor;CLEAR=erasevars/strings/arrays,argsyntaxUNCONF-seeOPENUNRESOLVEDblock;STRS(n)=reservestringspace,notneededeveryprogram,onlyheavystringwork} GRAPHICS{HIRES/HIRES2/LORES/PCG selectmode,mustsetbeforeSET/RESET/PLOTinthatmode;SET(H)x,y RESET(H)x,y=togglepoint;HIRESrangex0-511y0-255;LORESrangex0-127y0-63;PLOTx1,y1 TOx2,y2[TOx3,y3..]=connectedlines;PLOTx,y singlepair NOTO=setsONEpoint sameasSET,CONFreal(LORES.MWB);POINT(x,y)->-1ifset,-1ifOUTOFRANGEtoo,0ifnotset&inrange-treatANYnonzero=occupied} POKE{POKEe1,e2writese2toaddre1;NEGATIVEaddressesusedforhighmem,signed16bitrepr,CONFreal:POKE-3073,92=realaddr62463(65536-3073)} MISC{SEARCH(s1,s2[,n])findsnthoccurrence,ndefault1,bothformsCONFreal;FNn=expr-using-#(n=1-7,#=placeholder),callasFNn(arg);USR(addr[,bc])machinecodecall,bcdefault0ifomitted;numericfnsCONFreal:ABSATAN COS EXP FLT(int->real)FRACT INT(real->int)LOG RND SGN SIN SQR;RND->real0-1;rangedrandint:INT(RND*n)=0ton-1,INT(RND*n)+1=1ton} LOOKUPFALLBACK{thisfilecoversgotchas+confirmedpatterns,NOTeverycommand;formissingcmds usewebfetch/search:mbee.compoutpost.com/basic-reference/CMDNAME.php(lowercase,e.g.dim.phpkey.phppoint.php)=alphabeticalref,quicksyntax+1example each;fullofficialmanualw/workedexamples+STATEMENTS summary:cvxmelody.net/MicroBee%20Owners%20Manual%20(Supplement%20to%20Your%20Computer%20February%201982).pdf} MISTAKESALREADYMADE_DONOTREPEAT{usedINKEY$(wrong,useKEY$orKEY);thoughtnosubstringexistedatall(wrong,MID$/LEFT$absentbut(;a,b)indexingISreal,seeSTRINGS);usedbareK$(wrong,strvars=letter+digit+$,useK1$);wroteDIMM$(20)forstringarray(wrong,DIMM0(20)thenM0$(i));bareassignafterTHEN/ELSEnoLET(wrong forfirststmtrightafterTHEN/ELSE,seeIFTHENELSE);missedNEXT*inv1despitebeingaskedbyname} OPENUNRESOLVED_TREADCAREFULLY{UNCONF CLEARargsyntax(manualbareCLEARonly,no realprogram usesargform,bareCLEARsafe,CLEARnUNCONF);UNCONFmystery"."prefixedtokens(". 6"". "I",2,file"".MA1$4352")(grlobagr+beedat70)filestream/OPENrelatedfromcontext,undecoded,notchased,irrelevantwithoutdiskI/O;UNCONFINPUTnoseparatorbetweenpromptandvar(INPUT"YOURNAME"N1$)(bounce,1x)contradictsdocumentedcomma/semicolon,couldbedetokartifact,useINPUT"x";varorINPUT"x",varCONFsafe;UNCONFPLAYvariants(harry,1x)notmatchingdocumentedPLAYn[,m]:"PLAY,14"leadingcommanonotenum(guess=silence/pause),"PLAY23;20;23;20"semicolon4vals(guess=chainednote/durpairs),useplainPLAYnorPLAYn,mCONFsafeuntilconfirmed} TOKENTABLE_FORDETOKENISING{tworealvariantsexist,tryboth,scorebycountofrealflowkeywordhits(PRINTREMFORNEXTGOTOGOSUBRETURNCLSIFTHENDATAINPUT),higherscorewins;ROMvariant startsLETat0x80sequentially through0xdeCHR;CATvariant sameorder shifted+1 startsLETat0x81through0xdfCHR;fullorderbothvariants:LETLPRINTPRINTIFNEWLLISTLISTELSETHENFORNEXTDIMGOTOOFFONSTOPENDGOSUBREADDATARETURNINPUTRUNRESTORETOSTEPTABSPCFNVARPOKEOUTREMPRMTZONESDCLEAREDITSETRESETSPEEDNORMALUNDERLINESAVELOADSTRSINVERSEPCGCURSNOTANDORTRACECONTCLSHIRESAUTOINVERTLORESINTINPEEKUSRLENSEARCHPOINTERRORPOSASCUSEDNETPAKMENUGXABSRNDFLTFREVALFRACTSGNSQRSINCOSATANLOGEXPPLOTDELETERENUMPLAYEXECSTRKEYCHR}