Greetings knowledgeable.

How can I organize this subject? Ie I have a program, say the menu, and from this menu, I need to call .pas files or compiled exe from these passes to run. Preferably with an example.

Thank you in advance.

    3 answers 3

    To .exe compile .pas what for you, use the Pascal compiler.

    And to run the file there is a command

    Uses Dos begin Exec(ProgramName, CmdLine); // где ProgramName - название программы вместе с путем до ней // CmdLine параметры командной строки, если программа может принимать эти самые параметры. end; 

    and remember that exec is a procedure. Procedure Exec (Path, CmdLine: String);

      On Free Pascal, I did this:

        Uses CRT, Windows, ShellAPI; Begin ClrScr; // Z5.exe - это у меня одна из задач на Паскале (лежит в каталоге с этой прогой) Case WinExec(PChar('Z5.EXE'), SW_ShowNormal) Of 0: WriteLn('Не хватает памяти или других ресурсов!'); ERROR_BAD_FORMAT: WriteLn('Неправильный формат исполняемого файла!'); ERROR_FILE_NOT_FOUND: WriteLn('Не найден указанный файл!'); ERROR_PATH_NOT_FOUND: WriteLn('Не найден указанный путь!'); Else; End; Repeat Until KeyPressed; End. 

      WinExec (PChar ('full file name'), as show window) - the second parameter has 3 values:

      • SW_ShowMaximized - the window is maximized
      • SW_ShowMinimized - the window is minimized
      • SW_ShowNormal - normal window view

      PS At Turbo Pascal, this is most likely not a ride, because Turbo Pascal is already old and hardly supports WinAPI.

      • And here Free Pascal? Although the difference is really no other than the name of the procedure. - Artem
      • Turbo Pascal I do not compile it - can not find the specified modules. - DelphiM0ZG
      • Use Dos. Well pascal only works with DOS. - Artem
      • Turbo Pascal may not compile, but Delphi is supposed to (if ClrScr remove) - insolor
      • Yes, Delphi will compile this way (if you remove CRT and all functions from this module). - DelphiM0ZG

      So. Go to the file you want to run from the menu (pas file). In Turbo Pascal 7.0 you need to go to Compile -> Destination -> Disk. Click Save and run or compile. Next, here is the program:

       Program meny; Uses crt, dos; Var a:integer; Begin writeln('Enter 1 to start program or 0 to exit'); readln(a); if a = 1 then exec('Путь к файлу exe') else exit; 

      But there is one BUT. In Linux, how to run .exe? Win-format. I don't know linux well. And I do not know if your program will go. And put the path to the executable file in Linux format. I think it was useful. Good luck in programming.