Page 1 of 2
[done] RunProgram whis text
Posted: Mon Mar 03, 2025 9:29 am
by mestnyi
They made comments to me, so I'm creating a new topic.
Code: Select all
text$ = "Window_1 = OpenWindow(#PB_Any, 0, 0, 200, 200, "+Chr('"')+"window_1"+Chr('"')+ ")" + #LF$ +
"Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow"
RunProgram(#PB_Compiler_Home+"/Compilers/pbcompiler", "/EXE"+ text$, "", #PB_Program_Open|#PB_Program_Wait )
;RunProgram(#PB_Compiler_Home+"/Compilers/pbcompiler", text$ + " /EXE", "", #PB_Program_Open|#PB_Program_Wait )
AZJIO wrote: Mon Mar 03, 2025 5:13 am
1. This topic is to correct documentation errors, and not to resolve other issues.
2. This is not autoit3, so it is impossible to do this. Firstly, you need to save the file, and secondly, you cannot add the compiler to your program, since the license does not allow.
For example, in pureform, in icedesign there is a preview function, I thought it was implemented this way.
Re: RunProgram whis text
Posted: Mon Mar 03, 2025 10:03 am
by AZJIO
mestnyi wrote: Mon Mar 03, 2025 9:29 am
For example, in pureform, in icedesign there is a preview function, I thought it was implemented this way.
Looking at source code and compiling are different things.
Re: RunProgram whis text
Posted: Mon Mar 03, 2025 10:12 am
by infratec
Simply try to run the output in a dos-box:
Code: Select all
text$ = "Window_1 = OpenWindow(#PB_Any, 0, 0, 200, 200, "+Chr('"')+"window_1"+Chr('"')+ ")" + #LF$ +
"Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow"
Debug #PB_Compiler_Home+"/Compilers/pbcompiler" + " " + "/EXE"+ text$
Re: RunProgram whis text
Posted: Mon Mar 03, 2025 11:34 am
by Axolotl
I would have thought that the compiler always needs a file ?
Even if it is one line and the compiler is enclosed with doublequotes, the following error message is displayed:
Command Line:
Code: Select all
"C:\Program Files\PureBasic\/Compilers/pbcompiler" /EXE Window_1 = OpenWindow(#PB_Any, 0, 0, 200, 200, "window_1") : Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
Results in
Code: Select all
C:\Users\andre>"C:\Program Files\PureBasic\/Compilers/pbcompiler" /EXE Window_1 = OpenWindow(#PB_Any, 0, 0, 200, 200, "window_1") : Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
PureBasic 6.20 (Windows - x64)
Compiling WaitWindowEvent()=#PB_Event_CloseWindow
Loading external libraries...
Error: File not found (WaitWindowEvent()=#PB_Event_CloseWindow).
If you also enclose the entire parameter in double quotes, you get this:
Code: Select all
PureBasic 6.20 (Windows - x64) - (c) 2025 Fantaisie Software
A source filename need to be specified.
Type 'pbcompiler /?' for quick help.
So my suggestion: Save the text in a file and call that one.
Re: RunProgram whis text
Posted: Mon Mar 03, 2025 4:47 pm
by mestnyi
infratec wrote: Mon Mar 03, 2025 10:12 am
Simply try to run the output in a dos-box:
Code: Select all
text$ = "Window_1 = OpenWindow(#PB_Any, 0, 0, 200, 200, "+Chr('"')+"window_1"+Chr('"')+ ")" + #LF$ +
"Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow"
Debug #PB_Compiler_Home+"/Compilers/pbcompiler" + " " + "/EXE"+ text$
I did as you said and what did you mean by that?

Re: RunProgram whis text
Posted: Mon Mar 03, 2025 4:49 pm
by mestnyi
Axolotl wrote: Mon Mar 03, 2025 11:34 am
So my suggestion: Save the text in a file and call that one.
I didn't want to save it, is there really no other solution?

Re: RunProgram whis text
Posted: Mon Mar 03, 2025 4:51 pm
by mestnyi
AZJIO wrote: Mon Mar 03, 2025 10:03 am
mestnyi wrote: Mon Mar 03, 2025 9:29 am
For example, in pureform, in icedesign there is a preview function, I thought it was implemented this way.
Looking at source code and compiling are different things.
I don't understand what you mean.
it would seem a simple task, but there is not even any desire to continue working.
Re: RunProgram whis text
Posted: Mon Mar 03, 2025 5:43 pm
by Axolotl
mestnyi wrote: Mon Mar 03, 2025 4:49 pm
I didn't want to save it, is there really no other solution?
I know, so I checked this file
Code: Select all
; #PB_Compiler_Home + "SDK\CompilerInterface.txt"
for some hints.
Controlling the compiler /STANDBY with e.g. 'WriteProgramStringN()'
But there is always a source filename involved. Sorry, unfortunately I can't help you any better.
Re: RunProgram whis text
Posted: Mon Mar 03, 2025 10:00 pm
by ChrisR
I saw that my application was quoted.
For the preview, the generated code is written to a temporary file, compiled and then executed, as Axolotl wrote.
With a BIG thanks for the speed of the ASM compiler, to have the preview in less than 2 seconds.
Seeing the help, I didn't even try to do it any other way, with a string as parameter, a virtual NTFS file.
In all cases, creating a temporary file is the simplest and easiest way.
Re: RunProgram whis text
Posted: Wed Mar 05, 2025 8:42 am
by mestnyi
ChrisR wrote: Mon Mar 03, 2025 10:00 pm
I saw that my application was quoted.
For the preview, the generated code is written to a temporary file, compiled and then executed, as Axolotl wrote.
With a BIG thanks for the speed of the ASM compiler, to have the preview in less than 2 seconds.
Seeing the help, I didn't even try to do it any other way, with a string as parameter, a virtual NTFS file.
In all cases, creating a temporary file is the simplest and easiest way.
Can you give me the code for how you did it?
Re: RunProgram whis text
Posted: Wed Mar 05, 2025 10:14 am
by AZJIO
Code: Select all
; Execute the source code on the clipboard.
EnableExplicit
Procedure.s TmpFile(DirName$ = "", Prefix$ = "~", Ext$ = ".tmp", RandomLength = 7)
Protected TmpName$
If RandomLength < 4 Or RandomLength > 130
RandomLength = 7
EndIf
If Not Asc(DirName$) Or FileSize(DirName$) = -1
DirName$ = GetTemporaryDirectory()
EndIf
If Not CheckFilename(Prefix$)
Prefix$ = "~"
EndIf
If Not CheckFilename(Ext$)
Ext$ = ".tmp"
EndIf
If Right(DirName$, 1) <> #PS$
DirName$ + #PS$
EndIf
If Asc(Ext$) And Left(Ext$, 1) <> "."
Ext$ = "." + Ext$
EndIf
Repeat
TmpName$ = ""
While Len(TmpName$) < RandomLength
TmpName$ + Chr(Random(122, 97))
Wend
TmpName$ = DirName$ + Prefix$ + TmpName$ + Ext$
Until FileSize(TmpName$) = -1
ProcedureReturn TmpName$
EndProcedure
Define path$, code$, id_file, compiler$
path$ = TmpFile("", "", ".pb")
code$ = GetClipboardText()
id_file = CreateFile(#PB_Any, path$)
If id_file
WriteStringFormat(id_file, #PB_UTF8)
WriteString(id_file, code$)
CloseFile(id_file)
EndIf
If FileSize(path$) < 0
MessageRequester("Error", "Source not found" + #CRLF$ + #CRLF$ + path$)
End
EndIf
compiler$ = #PB_Compiler_Home + "Compilers\pbcompiler.exe"
; Debug compiler$
; Debug FileSize(compiler$)
; Debug path$
; Debug FileSize(path$)
RunProgram(compiler$,
#DQUOTE$ + path$ + #DQUOTE$ + " /DPIAWARE -q /EXE " + #DQUOTE$ + path$ + ".exe" + #DQUOTE$, "",
#PB_Program_Wait | #PB_Program_Hide) ; #PB_Program_Hide - error output problem
If FileSize(path$ + ".exe") > 0
RunProgram(path$ + ".exe")
Else
MessageRequester("Compilation error", "Failed to get the executable file" + #CRLF$ + #CRLF$ + path$ + ".exe")
EndIf
Re: RunProgram whis text
Posted: Wed Mar 05, 2025 10:59 am
by infratec
mestnyi wrote: Mon Mar 03, 2025 4:47 pm
infratec wrote: Mon Mar 03, 2025 10:12 am
Simply try to run the output in a dos-box:
Code: Select all
text$ = "Window_1 = OpenWindow(#PB_Any, 0, 0, 200, 200, "+Chr('"')+"window_1"+Chr('"')+ ")" + #LF$ +
"Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow"
Debug #PB_Compiler_Home+"/Compilers/pbcompiler" + " " + "/EXE"+ text$
I did as you said and what did you mean by that?
Then you will see that it is not working as you are expecting.
Re: RunProgram whis text
Posted: Wed Mar 05, 2025 11:52 am
by AZJIO
mestnyi wrote: Mon Mar 03, 2025 9:29 am
Code: Select all
#PB_Compiler_Home+"/Compilers/pbcompiler"
All constants and functions that are paths ALWAYS have "\" in them at the end of the line. Therefore, you should never start the second part of a file path with this character.
mestnyi wrote: Mon Mar 03, 2025 9:29 am
The path in the parameters should ALWAYS be in quotes.
Re: RunProgram whis text
Posted: Wed Mar 05, 2025 12:24 pm
by Axolotl
@AZJIO:
You may have overlooked the fact that he does not want to save the source code. But I think you have confirmed that it (only) works with a (temp) file.
Re: RunProgram whis text
Posted: Wed Mar 05, 2025 2:02 pm
by AZJIO
Axolotl wrote: Wed Mar 05, 2025 12:24 pm
@AZJIO:
You may have overlooked
Read the first message in this topic. It says that I didn't miss it
