Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   QBasic Compiler coden..? (https://www.delphipraxis.net/14676-qbasic-compiler-coden.html)

alanblack 14. Jan 2004 17:08

Re: QBasic Compiler coden..?
 
hi scp,

was bringt der code? verstehe ich nich so ganz..?
soll ich den im Delphi Script einfügen?
wenn ja wie? das kann nich so ganz stimmen oder das sind alles keine Delphi anweisungen?
erklär mir mal bitte wie das machen soll

mfg alan

scp 14. Jan 2004 17:18

Re: QBasic Compiler coden..?
 
Nein, dass sind die Parameter zum aufrufen, starten kannst du ihn von Delphi aus z.B. so:

Delphi-Quellcode:
var
  QBCompilerDir : String;
  QBCompiler : String;
  BASfile : String;

begin
  QBCompilerDir := 'C:\qb45'; // Ordner, in dem der Complier ist
  QBCompiler := 'bc.exe';
  BASfile := 'C:\BAS\meine.bas';
  ShellExecute(0, 'open', PChar(QBCompilerDir + '\' + QBCompiler), PChar(BASfile), PChar(QBCompilerDir), sw_ShowNormal);
end;

EConvertError 21. Feb 2004 10:13

Re: QBasic Compiler coden..?
 
Danke erstmal, aber ich hätte da noch 2 Fragen:
1)Wie bekomme ich die Compiler-Fehlermeldungen und Warnungen so wie in Delphi in mein Programm?

2)Gibt es da auch so etwas wie einen Debugger, damit ich Breakpoints und das ganze Zeugs machen kann? Und wenn ja, wie bedient man den von außen (und bekommt die Informationen ins Programm)?

Danke schon im voraus,
EConvertError

DP-Maintenance 21. Feb 2004 10:29

DP-Maintenance
 
Dieses Thema wurde von "Daniel" von "VCL-Komponenten und Controls" nach "Programmieren allgemein" verschoben.

orion3000 21. Feb 2004 10:54

Re: QBasic Compiler coden..?
 
Hallo versuchsmal mit der Function...

Delphi-Quellcode:
function GetConsoleOutput(const Command: String; var Output, Errors: TStringList): Boolean;
var
  StartupInfo: TStartupInfo;
  ProcessInfo: TProcessInformation;
  SecurityAttr: TSecurityAttributes;
  PipeOutputRead: THandle;
  PipeOutputWrite: THandle;
  PipeErrorsRead: THandle;
  PipeErrorsWrite: THandle;
  Succeed: Boolean;
  Buffer: array [0..255] of Char;
  NumberOfBytesRead: DWORD;
  Stream: TMemoryStream;
begin
  //Initialisierung ProcessInfo
  FillChar(ProcessInfo, SizeOf(TProcessInformation), 0);

  //Initialisierung SecurityAttr
  FillChar(SecurityAttr, SizeOf(TSecurityAttributes), 0);
  SecurityAttr.nLength := SizeOf(SecurityAttr);
  SecurityAttr.bInheritHandle := true;
  SecurityAttr.lpSecurityDescriptor := nil;

  //Pipes erzeugen
  CreatePipe(PipeOutputRead, PipeOutputWrite, @SecurityAttr, 0);
  CreatePipe(PipeErrorsRead, PipeErrorsWrite, @SecurityAttr, 0);

  //Initialisierung StartupInfo
  FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
  StartupInfo.cb:=SizeOf(StartupInfo);
  StartupInfo.hStdInput := 0;
  StartupInfo.hStdOutput := PipeOutputWrite;
  StartupInfo.hStdError := PipeErrorsWrite;
  StartupInfo.wShowWindow := sw_Hide;
  StartupInfo.dwFlags := STARTF_USESHOWWINDOW or STARTF_USESTDHANDLES;

  if CreateProcess(nil, PChar(command), nil, nil, true,
  CREATE_DEFAULT_ERROR_MODE or CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil,
  StartupInfo, ProcessInfo) then begin
    result:=true;
    //Write-Pipes schließen
    CloseHandle(PipeOutputWrite);
    CloseHandle(PipeErrorsWrite);

    //Ausgabe Read-Pipe auslesen
    Stream := TMemoryStream.Create;
    try
      while true do begin
        succeed := ReadFile(PipeOutputRead, Buffer, 255, NumberOfBytesRead, nil);
        if not succeed then break;
        Stream.Write(Buffer, NumberOfBytesRead);
      end;
      Stream.Position := 0;
      Output.LoadFromStream(Stream);
    finally
      Stream.Free;
    end;
    CloseHandle(PipeOutputRead);

    //Fehler Read-Pipe auslesen
    Stream := TMemoryStream.Create;
    try
      while true do begin
        succeed := ReadFile(PipeErrorsRead, Buffer, 255, NumberOfBytesRead, nil);
        if not succeed then break;
        Stream.Write(Buffer, NumberOfBytesRead);
      end;
      Stream.Position := 0;
      Errors.LoadFromStream(Stream);
    finally
      Stream.Free;
    end;
    CloseHandle(PipeErrorsRead);

    WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
    CloseHandle(ProcessInfo.hProcess);
  end
  else begin
    result:=false;
    CloseHandle(PipeOutputRead);
    CloseHandle(PipeOutputWrite);
    CloseHandle(PipeErrorsRead);
    CloseHandle(PipeErrorsWrite);
  end;
end;

Aufruf der Funktion

Delphi-Quellcode:
procedure TForm1.BitBtn1Click(Sender: TObject);
var Output, Errors: TStringList;
begin
Output:=Tstringlist.Create;
Errors:=TStringList.Create;
GetConsoleOutput('attrib.exe C:\*.*',Output,Errors);
listbox1.Items.Text:=output.Text;
listbox2.Items.Text:=Errors.Text;
Errors.free;
Output.Free;
end;

Gruß Orion3000

EConvertError 22. Feb 2004 09:08

Re: QBasic Compiler coden..?
 
Danke, das sieht gut aus.

Genial wäre jetzt noch, wenn noch jemand wüsste wie ich einen Debugger realisieren kann (oder wie ich den QBasic Debugger ansteuern kann).

mfg,
EConvertError


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:45 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz