Can you run a RMK file from an exe?

Can you run a RMK file from an exe?

Postby hag » Mon Mar 07, 2011 2:40 am

Can you run a RMK file from an exe? If so how?
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Re: Can you run a RMK file from an exe?

Postby ukoenig » Mon Mar 07, 2011 11:00 am

Hello Harvey,

The part from the Tools, to create a Exe-File :
F needed, You can call a Editor to check the PRG, before creating a EXE-file
You can find < Angelwriter > in the Main-directory of the Tools.

Code: Select all  Expand view

FUNCTION MAKE_Exe()

c_path := CURDRIVE() + ":\" + GETCURDIR()  

IF FILE ( c_path + "
\PROJECT.PRG" )
    // If File exists open with Editor
    WAITRUN( "
Angelwriter.exe PROJECT.PRG" ) // Open PRG with Editor
    // Close Editor and create EXE-File
    IF MsgYesNo( "
Do you want to Create / Run : " + CRLF + ;
                            c_path + "
\PROJECT.PRG" + " ?","PROJECT")
                WAITRUN( "
GO1.BAT"  )
        IF FILE ( c_path + "
\PROJECT.EXE" )
            WINEXEC( "
&c_path\PROJECT.EXE" )
        ELSE
            MsgAlert( "
The EXE-File : " + CRLF + ;
                         "
is not created !","Error" )
        ENDIF
    ENDIF
ELSE
    MsgAlert( "
The File : " + CRLF + ;
            "
&c_Path\PROJECT.PRG" + CRLF + ;
            "
is not created !", "Error" )
ENDIF

RETURN(  NIL )


Save the 2 Lines as a BATCH-file
( change Path and Borland-version if needed )
The Batch-file GO1.BAT opens the defined MAKE-File :

Code: Select all  Expand view

IF not exist obj md obj
c:\bcc55\bin\make -f Project.rmk
 


CREATING a PRG from inside a Application ( NOT EASY !!! )
Sample : Background defines for Main-window
The defined numeric vars ( colors ) must be converted to Strings

Code: Select all  Expand view

FUNCTION MAKE_PRG(nOption1,nOption2)

IF FILE ( c_path + "\PROJECT.PRG" )
   DELETE FILE  "&c_path\PROJECT.PRG"
ENDIF

oText := TTxtFile():New( c_path + "\PROJECT.PRG" )

IF oText:Open()
   oText:Add('#include "fivewin.ch"' )
   oText:Add('')
   oText:Add('STATIC hDC, oWndMain, oFont1' )
   oText:Add('STATIC c_path' )  
   oText:Add('')
   oText:Add('FUNCTION MAIN()')
   oText:Add('LOCAL oBar, aColors1,aColors2,aColors3' )
   oText:Add('LOCAL oBtn1, oBtn2, oBtn3, oBtn4' )
   oText:Add('LOCAL oTmp, oBrush1, oBrush2, oBrush3, oBrush4' )
   oText:Add('LOCAL aRect3 := GetSysmetrics( 1 ) // Screen-Height' )
   oText:Add('LOCAL aRect4 := GetSysmetrics( 0 ) // Screen-Width' )
   oText:Add('')
   oText:Add('c_path := CURDRIVE() + ":\" + GETCURDIR()' )
   oText:Add('oFont1 := TFont():New( "' + AF + '",' + A1 + ',' + A2 + ',.F.,' + A3 + ',' + A4 + ',0,0,' + A5 + ',' + A6 + ')' )
   oText:Add('')
   IF nOption1 = 1 // Window with Color selected
      oText:Add('DEFINE BRUSH oBrush1 COLOR ' + ALLTRIM(STR(nColor1a))  )
      oText:Add('DEFINE WINDOW oWndMain FROM 0, 0 TO aRect3, aRect4 TITLE "Window- and Dialog-test"  BRUSH oBrush1 PIXEL' )
   ENDIF
   IF nOption1 = 2 // Windows with Gradient selected
      oText:Add('DEFINE WINDOW oWndMain FROM 0, 0 TO aRect3, aRect4;' )  
      oText:Add('TITLE "Window- and Dialog-test"  PIXEL' )
      oText:Add('aColors1 := { { ' + ALLTRIM(STR(nMove1)) + ', ' + ALLTRIM(STR(nColor1a)) + ', ' + ALLTRIM(STR(nColor1b)) + ' }, { ' +  + ALLTRIM(STR(nMove1)) + ', '  + ALLTRIM(STR(nColor1b)) + ', '  + ALLTRIM(STR(nColor1a)) + ' } }' ) 
      oText:Add('hDC = CreateCompatibleDC( oWndMain:GetDC() )' )
      oText:Add('hBmp = CreateCompatibleBitMap( oWndMain:hDC, oWndMain:nWidth(), oWndMain:nHeight() )' )
      oText:Add('hBmpOld = SelectObject( hDC, hBmp )' )
      oText:Add('GradientFill( hDC, -50, 0, oWndMain:nHeight(), oWndMain:nWidth(), aColors1, lDirect1 )' )
      oText:Add('DeleteObject( oWndMain:oBrush:hBrush )' )
      oText:Add('oWndMain:oBrush:hBitmap = hBmp' )
      oText:Add('oWndMain:oBrush:hBrush = CreatePatternBrush( hBmp )' )
      oText:Add('SelectObject( hDC, hBmpOld )' )
      oText:Add('oWndMain:ReleaseDC()' )
   ENDIF
   IF nOption1 = 3 // Windows with Brush selected
      oText:Add('DEFINE BRUSH oBrush1 FILENAME c_Path + "\bitmaps' + cBrush1 + '"' )
      oText:Add('DEFINE WINDOW oWndMain FROM 0, 0 TO aRect3, aRect4;' )
      oText:Add('TITLE "
Window- and Dialog-test"  BRUSH oBrush1 PIXEL' )
   ENDIF
   IF nOption1 = 4 // Windows with Image selected
      oText:Add('DEFINE IMAGE oTmp FILENAME c_Path + "
\bitmaps\' + cImage1 + '"' )
      oText:Add('oBrush1 := TBrush():new( ,,,, ResizeBmp( oTmp:hBitmap, aRect4, aRect3, .T. ) )' )
      oText:Add('DEFINE WINDOW oWndMain FROM 0, 0 TO aRect3, aRect4 ;' )
      oText:Add('TITLE "
Window- and Dialog-test"  BRUSH oBrush1 PIXEL' )
      oText:Add('oTmp:End()' )
   ENDIF
   IF nPreview > 1
      oText:Add('ACTIVATE WINDOW oWndMain MAXIMIZED ;' )
      oText:Add('ON INIT MDI_DIALOG() ;' )
      oText:Add('ON PAINT ABPaint( hDC, 30, 380, oAlpha:hBitmap, 255 )  // Horiz / Vertical' )
   ELSE
      oText:Add('ACTIVATE WINDOW oWndMain MAXIMIZED ;' )
      oText:Add('ON PAINT ABPaint( hDC, 30, 380, oAlpha:hBitmap, 255 )  // Horiz / Vertical' )
   ENDIF
   oText:Add('')
   oText:Add('SET MESSAGE OF oWndMain TO FWVERSION + "
 TechData Software " ;' )
   oText:Add('CENTERED 2007' )
   oText:Add('')
   oText:Add('oFont1:End()' )
   IF nOption1 <> 2
      oText:Add('oBrush1:End()' )
   ENDIF
   IF nOption2 <> 2
      oText:Add('oBrush2:End()' )
   ENDIF
   oText:Add('')
   oText:Add('RETURN NIL' )  
   oText:Add('')

   oText:Close()
ENDIF

IF FILE ( c_path + "
\PROJECT.PRG" )
   // File exists open with Editor
   WAITRUN( "
Angelwriter.exe PROJECT.PRG" ) // copy from .PRG
   // Close Editor and create EXE-File
   IF MsgYesNo( "
Do you want to Create / Run : " + CRLF + ;
      c_path + "
\PROJECT.PRG" + " ?","PROJECT")
      WAITRUN( "
GO1.BAT"  )
      IF FILE ( c_path + "
\PROJECT.EXE" )
         WINEXEC( "
&c_path\PROJECT.EXE" )
      ELSE
         MsgAlert( "
The EXE-File : " + CRLF + ;
         "
is not created !","Error" )
      ENDIF
   ENDIF
ELSE
   MsgAlert( "
The File : " + CRLF + ;
         "
&c_Path\PROJECT.PRG" + CRLF + ;
         "
is not created !", "Error" )
ENDIF

RETURN(  NIL )


Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 64 guests