使用例(MEMORY.DLLをBASIC.EXEと同じフォルダに置くか,MEMORY.DLLを置くフォルダにプログラムを保存してから実行してください)
DECLARE EXTERNAL FUNCTION GetMem, peek, peek2, peek4, PeekDouble LET p=GetMem(28) if p<>0 then FOR i=0 TO 4 CALL poke4(p+4*i,i) NEXT i LET a=PI CALL PokeDouble(p+4*i,a) FOR i=0 TO 4 PRINT peek4(p+4*i) NEXT i PRINT PeekDouble(p+4*i) CALL FreeMem(p) END IF END EXTERNAL FUNCTION GetMem(n) assign "memory.dll","GetMem" END FUNCTION EXTERNAL SUB FreeMem(p) assign "memory.dll","FreeMem" END SUB EXTERNAL FUNCTION peek(p) assign "memory.dll","Peek" END FUNCTION EXTERNAL SUB poke(p,i) assign "memory.dll","Poke" END SUB EXTERNAL FUNCTION peek2(p) assign "memory.dll","Peek2" END FUNCTION EXTERNAL SUB poke2(p,i) assign "memory.dll","Poke2" END SUB EXTERNAL FUNCTION peek4(p) assign "memory.dll","Peek4" END FUNCTION EXTERNAL SUB poke4(p,i) assign "memory.dll","Poke4" END SUB EXTERNAL FUNCTION PeekDouble(p) SUB MoveM(p,s$,n) ASSIGN "Memory.dll","MoveM" END SUB LET s$=REPEAT$(CHR$(0),8) CALL MoveM(p,s$,8) LET PeekDouble=UnPackDBL(s$) END FUNCTION EXTERNAL SUB PokeDouble(p,a) SUB MoveM(s$,p,n) ASSIGN "Memory.dll","MoveM" END SUB CALL MoveM(PackDBL$(a),p,8) END SUBGetMem(n)は,nバイトのメモリーを確保し,先頭アドレスを返す(結果が0のときはメモリー確保に失敗)。