'Compilerdirectiven $compile exe $lib all off $lib iprint on $error all - 'Integer-Constanten %FALSE = 0 %TRUE = -1 'Dimensionierung der Variablen dim bool as shared integer ,_ text as shared string ,_ test as shared string ,_ ausg as shared string ,_ cmnd as shared string ' Hauptprogramm cmnd = ucase$(rtrim$(COMMAND$)) bool = batchRunning (batname$, batptr&, batsegm??) if bool then call batchman else print "Kein Batchaufruf!" END 1 end if END 0 'Funktionen, Prozeduren function batchRunning ( batch$, ptr&, proc?? ) local dim offset as local integer,_ j as local integer,_ suchen as local string ,_ pPSP as local word ,_ comSpc as local string ,_ comLen as local byte ,_ adress as local word comSpc=environ$("COMSPEC")+chr$(0) comLen=len(comSpc) 'PSP des Programmladers (COMMAND) ! mov ah, &H51 ! int &H21 ! mov es, bx ! mov bx, word ptr es:[&H16] ! mov pPSP, bx 'Adresse Batchinfo ermitteln def seg = pPSP offset = 0 do suchen = peek$(offset, comLen) j = instr(suchen, comSpc) if j > 0 then exit loop incr offset loop adress = peeki(offset-2) batch$ = "" if adress = 0 then batchRunning = %FALSE exit function else batchRunning = %TRUE def seg = adress offset = &H20 do batch$=batch$+peek$(offset, 1) incr offset loop until peek(offset) = 0 'batch$ mit Pfad+Namen offset = &H08 ptr& = peekL (offset) 'ptr& mit aktuellem Filepointer proc?? = adress 'proc?? Adr.Kommandoprozessor end if end function sub batchman shared if cmnd="TEXT" OR cmnd="KOMM" then open batname$ for binary as #1 seek #1, batptr& do get$ #1, 1, x$ text=text + x$ test=ucase$(right$(text,4)) loop until test = "$END" ausg=left$(text,len(text)-4) ausg=remove$(ausg,chr$(10)) while x$ <> chr$(13) get$ #1, 1, x$ wend batptr& = seek(1) close #1 if cmnd="TEXT" then print ausg; setFilePointer elseif cmnd = "RUN" then batptr& = 0 setFilePointer elseif cmnd = "QUIT" then open batname$ for input as #1 batptr& = lof(1) close #1 setFilePointer elseif cmnd = "UPPER" then def seg = batsegm?? pOffs?? = peek(&H0C) do char$=ucase$(chr$(peek(pOffs??))) poke$ pOffs??, char$ incr pOffs?? loop until peek(pOffs??) = 0 def seg elseif cmnd = "CMDLN" then def seg = batsegm?? pOffs?? = peek(&H0E) do y? = peek(pOffs??) if y? = 13 then poke pOffs??, 32 incr pOffs?? loop until y? = 0 def seg elseif cmnd = "" then END 2 else END 3 end if end sub sub setFilePointer shared def seg = batsegm?? pokel 8, batptr& def seg end sub