Page 1 of 1

RunProgram: can't get all the list of errors

Posted: Sat Dec 16, 2023 7:09 pm
by morosh
Hello:
I'm using the following snippet but I can't get all the errors I normally got with a command line:

Code: Select all

Define fname.s, tmp.s

fname=OpenFileRequester("Choose File:","","Asm (*.asm)|*.asm",0)

prog=RunProgram("E:\install\dvd1\dev_soft\assembly\FASM\fasm",fname,"",#PB_Program_Hide | #PB_Program_Open | #PB_Program_Read |  #PB_Program_Error)
While ProgramRunning(prog)
  If AvailableProgramOutput(prog)
    tmp="* "+ReadProgramString(prog)
    Debug tmp
    tmp = ReadProgramError(prog)  
    If tmp
      tmp="/ "+tmp
      Debug tmp
    EndIf
  EndIf
Wend
If ProgramExitCode(prog) <> 0
  tmp = "+ "+ReadProgramError(prog)
  Debug tmp
EndIf
The program is "fasm.exe", I made intentional errors in my asm file (no label1), in a command window I get:
flat assembler version 1.73.31 (1048576 kilobytes memory)
test1.asm [62]:
jmp label1
processed: jmp label1
error: undefined symbol 'label1'.
In PB, running the previous snippet, I got:
* flat assembler version 1.73.31 (1048576 kilobytes memory)
+ E:\my_data\prog\asm8086\emu8086\test1\test1.asm [62]:
just the two first lines, the last lines don't appear.
what's wrong?

Any help is appreciated

Re: RunProgram: can't get all the list of errors

Posted: Sat Dec 16, 2023 7:33 pm
by infratec
Try this:

Code: Select all

EnableExplicit

Define fname.s, tmp.s, OutBytes.i, *Buffer, prog.i

fname=OpenFileRequester("Choose File:","","Asm (*.asm)|*.asm",0)
If fname  
  *Buffer = AllocateMemory(1024)
  If *Buffer
    prog=RunProgram("E:\install\dvd1\dev_soft\assembly\FASM\fasm",fname,"",#PB_Program_Hide | #PB_Program_Open | #PB_Program_Read |  #PB_Program_Error | #PB_Program_UTF8)
    If prog
      While ProgramRunning(prog)
        OutBytes = AvailableProgramOutput(prog)
        If OutBytes > 0
          ReadProgramData(prog, *Buffer, OutBytes)
          tmp="* " + PeekS(*Buffer, OutBytes, #PB_UTF8|#PB_ByteLength)
          Debug tmp
        EndIf
        
        tmp = ReadProgramError(prog, #PB_UTF8)  
        If tmp
          tmp="/ "+tmp
          Debug tmp
        EndIf
      Wend
      
      If ProgramExitCode(prog) <> 0
        tmp = "+ "+ReadProgramError(prog, #PB_UTF8)
        Debug tmp
      EndIf
      
      CloseProgram(prog)
    EndIf
    FreeMemory(*Buffer)
  EndIf
EndIf
AvailableProgramOutput() has nothing to do with the error output.

Re: RunProgram: can't get all the list of errors

Posted: Sat Dec 16, 2023 9:22 pm
by morosh
Works like a charm!!!!
Thank you very much