PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Heinz Grandjean on March 16, 2013, 08:44:45 AM

Title: start FireFly using "shell"
Post by: Heinz Grandjean on March 16, 2013, 08:44:45 AM
Hello,
I want to start FireFly36.exe from another PB-compiled program by using:

SHELL "C:\Program Files (x86)\FireFly Visual Designer 3.62\FireFly36.exe /"

So far; FireFly opens.
Now I have two questions:
1)How can I then load a project into Firefly
2)Is there maybe a command Switch to let it compile the project.
I have checked the Firefly- help file with no result.
But this could depend on me...

Thanks for help,
Heinz Grandjean
Title: Re: start FireFly using "shell"
Post by: Eddy Van Esch on March 16, 2013, 11:55:15 AM
You could control FF (or any other program) by using AutoIt. It is a tool to control and send commands to other applications.
http://www.autoitscript.com/site/
Title: Re: start FireFly using "shell"
Post by: Eddy Van Esch on March 16, 2013, 12:05:32 PM
Or you can use my 'SendString' command to send keystrokes or Menu calls to FF.
http://www.powerbasic.com/support/pbforums/showthread.php?t=40567&highlight=sendinput
Title: Re: start FireFly using "shell"
Post by: Eddy Van Esch on March 16, 2013, 12:34:08 PM
On second though, Heinz. FF does not compile. The PowerBASIC compiler does this!
The PB compiler has a command line interface, so you can compile your program by SHELL'ing the PB compiler with the required parameters (your source code file etc.).
http://www.powerbasic.com/support/help/pbwin/index.htm
--> click 'Running PBWin', then click 'Running PB/Win From The Command Prompt '

Title: Re: start FireFly using "shell"
Post by: Heinz Grandjean on March 17, 2013, 02:49:07 AM
Eddy, thank you very much for your friendly help!

Your "second thought" is the real problem that I wanted to come around by "calling" the firefly editor.
Please allow me to describe it:
I have no success in calling the PB10-Compiler using the shell-command when I want it to compile a firefly
CODEGEN_MAIN.bas.
The CODEGEN_MAIN.bas is made by Firefly 3.62 using the J. Roca includes.
I tried to use the following lines (here separated for demonstrating purpose):
(Sorry, there are some German filespecs. )

Compiler and J. Roca folder:
shell "C:\PBWin10\bin\PBWin.exe /I\;D:\ESTWGJ_QUELL\J.Roca\WinApi_III_1_03\WINAPI_III;

followed by the CODEGEN-Main folder:
D:\ESTWGJ_QUELL\PBWin10_Prj\ESTWGJ_DLL_V6\IsoLaenge\release 

followed by the firefly Main.bas and the return-value:
D:\ESTWGJ_QUELL\PBWin10_Prj\ESTWGJ_DLL_V6\IsoLaenge\release\ Codegen_IsoLaenge_Main.bas"  EXIT to lExeRetrun

The PB10-Compiler starts compiling but always stops, showing:
Error 478 in: "..." Line 118: #Resource RES, "CODEGEN_ISOLAENGE_RESOURCE.res"
I do not know how to come around that error or simply: How is the correct shell command for a Firefly generated main.bas.
By the way "normal" *.bas -files , generated by the PB10-IDE or UltraEdit don't make any problems.

Thank You again,
Heinz Grandjean
Sorry, I can't get out that stupid smiley...
Title: Re: start FireFly using "shell"
Post by: Eddy Van Esch on March 17, 2013, 05:52:07 AM
Quote from: Heinz Grandjean on March 17, 2013, 02:49:07 AM
Compiler and J. Roca folder:
shell "C:\PBWin10\bin\PBWin.exe /I\;D:\ESTWGJ_QUELL\J.Roca\WinApi_III_1_03\WINAPI_III;
followed by the CODEGEN-Main folder:
Heinz,
Maybe there is a dot missing where I indicated the text in bold red.
I think it should be: /I.\;   Notice the extra dot betweeen I and \


Title: Re: start FireFly using "shell"
Post by: Heinz Grandjean on March 17, 2013, 06:22:39 AM
Eddy,
thanks again. The dot makes no difference. It is a problem with the Resource -file.
It would be interesting to know in which way Firefly calls the PBWin10-compiler.
There could be the solution.

Heinz Grandjean
Title: Re: start FireFly using "shell"
Post by: Eddy Van Esch on March 17, 2013, 06:59:18 AM
Is the .RES resource file located in the 'release' folder? Or otherwise in some other included folder?
FF compiles the .rc resource file into a .res resource file and puts that in the release folder.
I assume you have not set the option to 'Delete generated code after compile' in Project Properties ? Otherwise, the .res file is deleted.
Title: Re: start FireFly using "shell"
Post by: Heinz Grandjean on March 17, 2013, 07:49:45 AM
Yes, the resource-file is inside the release-folder.
The Compiler finds it and then creates the above mentioned error-message.
By the way, compiling using firefly works ok.

Thanks,
Heinz Grandjean
Title: Re: start FireFly using "shell"
Post by: Paul Squires on March 17, 2013, 12:06:51 PM
I haven't tested any of this (it's Sunday here in Newfoundland) but it looks like the resource file is not being found because you have not first set the working directory to the Release folder. When FireFly compiles it first makes the Release folder the active folder (CHDIR) and then generates the source and compiles it.

The code in the CODEGEN_*MAIN.BAS file for the Resource is like the following:

#Resource RES, "CODEGEN_INSIGHT_RESOURCE.res"

Therefore, the compiler expects to find it in the current folder.

FireFly creates a temp file that is fed to the PB compiler. It contains all of the command line switches, etc. That filename is called "_compiletemp.tmp" and is deleted once the Shell to the compiler is completed.

Here is the exact code that FireFly uses:

   ' Break the Include path down into its component paths if necessary.
   i = ParseCount( gclsCodeGen.PBINCLUDE, ";" )
   For x = 1 To i
      st = st & $Dq & Trim$(Parse$(gclsCodeGen.PBINCLUDE, ";", x)) & $Dq & ";"
   Next                                                             
   st = RTrim$( st, ";" )

   sSlashCFilename = "_compiletemp.tmp"
   f = FreeFile
   Open sSlashCFilename For Output As #f
   Print #f, " /I" & st & " /L /Q " & $Dq & FileNam(gclsCodeGen.WinMainFilename) & $Dq
   Close #f
   
   execmd = gclsCodeGen.PBCOMPILER & " /C" & sSlashCFilename

   ErrClear

   Shell execmd$, 0
   
   If Dir$(sSlashCFilename) > "" Then Kill sSlashCFilename


Title: Re: start FireFly using "shell"
Post by: Heinz Grandjean on March 18, 2013, 06:51:51 AM
Thank you Mr. Squires for waisting time on Sunday because of my lack of knowledge...

I tested your code carefully and I made a testing program using PPC6
FUNCTION PBMAIN () AS LONG
'*************************
LOCAL i                 AS LONG
LOCAL strInclude,strExe AS STRING
LOCAL f                 AS INTEGER
LOCAL lExeReturn        AS LONG

LOCAL strFolderName AS STRING
strFolderName = "_compiletemp.tmp"

LOCAL strProg AS STRING
strProg = "C:\PBWin10\bin\PBWin.exe"

LOCAL strMainfileName AS STRING
strMainfileName = PATHSCAN$(FULL, "Codegen_Isolaenge_DLL_Main.bas", "D:\ESTWGJ_QUELL\PBWin10_Prj\ESTWGJ_DLL_V6\IsoLaenge\release\")

DIM strInc(1 TO 5) AS STRING
'Location of J.Roca-Includes:
'----------------------------
strInc(1) = $DQ & "D:\ESTWGJ_QUELL\J.Roca\WinApi_III_1_03\WINAPI_III" & $DQ & ";"

'Location of Codegen-release-folder:
'-----------------------------------
strInc(2) = $DQ & "D:\ESTWGJ_QUELL\PBWin10_Prj\ESTWGJ_DLL_V6\IsoLaenge\release" & $DQ & ";"

'PB10-Resource-stuff (maybe not neccessary...)
'---------------------------------------------
strInc(3) = "C:\PBWin10\bin" & ";"

   'Generating the Include-String:
   '------------------------------
    FOR i = 1 TO 5
        IF LEN(strInc(i)) THEN
           strInclude += strInc(i)
        END IF
    NEXT i
    strInclude = RTRIM$(strInclude, ";" )
   'Making the folder:
   '------------------
    f = FREEFILE
    OPEN strFolderName FOR OUTPUT AS #f
      PRINT #f,  " /I" & strInclude & " /L " & $DQ & strMainfileName & $DQ
    CLOSE #f
   'Generating the complete Exe-String:
   '-----------------------------------
    strExe = strProg & " /C" & strFolderName
   'Shell-command:
   '--------------
    SHELL strExe, 0 EXIT TO lExeReturn
   'Checking results:
   '------------------
    ? lExeReturn: WAITKEY$
   'Killing the folder:
   '-------------------
    IF DIR$(strFolderName) > "" THEN
       KILL strFolderName
    END IF
END FUNCTION                       


But I always get Error 478:
Line 118:'resource Res, "Codegen_IsoLaenge_Dll_Resource.res"

The compiler finds the J.Roca-Include und the CODEGEN_MAIN.bas, but ...
When I omit the PBWin10/bin-folder the reults are the same.
Maybe you have time to overlook my code.
Thanks,
Heinz Grandjean
Title: Re: start FireFly using "shell"
Post by: Eddy Van Esch on March 18, 2013, 07:04:07 AM
Heinz,

What happens if you add the full path name in the #RESOURCE statement and then compile?
Change this:
#RESOURCE RES, "Codegen_IsoLaenge_Dll_Resource.res"
into:
#RESOURCE RES, "D:\ESTWGJ_QUELL\PBWin10_Prj\ESTWGJ_DLL_V6\IsoLaenge\release\Codegen_IsoLaenge_Dll_Resource.res"
Title: Re: start FireFly using "shell"
Post by: Heinz Grandjean on March 18, 2013, 07:41:50 AM
Eddy,
a very good idea.
I tested it and it does the job!!!!
Thank You for that.
But when I recompile using the original Firefly 3.62 it rewrites the pathname again to the original (simple) file name.
Now we come closer to the problem...

Heinz Grandjean
Title: Re: start FireFly using "shell"
Post by: Eddy Van Esch on March 18, 2013, 07:50:55 AM
Yes, FF regenerates the source code each time.
But now we know that there is nothing wrong with the .res file itself, but that the PB compiler can not find the resource file because apparantly it is not in the compiler include paths.
Are you sure there is nothing wrong with the list of include paths you pass to the compiler?

Worst case you can always replace the #resource line in your code by the full path version programmatically before compiling.
Effective, but not very elegant  .. :)
Title: Re: start FireFly using "shell"
Post by: Heinz Grandjean on March 18, 2013, 08:57:39 AM
Think, they are now correct.
PBWIN10 finds all the other stuff inside the Main-Release-folder.
There is -as you know- a lot of (simple) filenames in.
But it could be that a special Inc.-folder is missing inmy include-paths??
Heinz Grandjean
Title: Re: start FireFly using "shell"
Post by: Paul Squires on March 18, 2013, 12:58:24 PM
I noticed that you are not CHDIR to the Release folder in your code. The Resource statement is not fully path qulaified (like Eddy said) so you need to be in the Release folder before executing your SHELL statement.

Something like this:

CHDIR "D:\ESTWGJ_QUELL\PBWin10_Prj\ESTWGJ_DLL_V6\IsoLaenge\release\")
SHELL strExe, 0 EXIT TO lExeReturn
' change back to previous folder if necessary.
Title: Re: start FireFly using "shell"
Post by: Heinz Grandjean on March 18, 2013, 02:00:39 PM
That does the job!
Thank you very much , gentlemen.

Please allow me again one additional question:
Where can one find that information to change the directory before "shell" ???

Heinz Grandjean