scripts.prg
- Code: Select all Expand view RUN
- // Scripting for Harbour and FiveWin only (not supported on xHarbour)
#include "FiveWin.ch"
#include "Splitter.ch"
#include "xbrowse.ch"
static oWnd
function Main()
local oBrw, oFont, oMemo, oSplit
if ! File( "scripts.dbf" )
DbCreate( "scripts.dbf", { { "NAME", "C", 20, 0 }, { "DESCRIPT", "C", 100, 0 }, { "CODE", "M", 80, 0 } } )
endif
USE scripts
if RecCount() == 0
APPEND BLANK
Scripts->Name := "Test"
Scripts->Descript := "This is a test script"
Scripts->Code := "function Test()" + CRLF + CRLF + ' MsgInfo( "Hello world!" )' + CRLF + CRLF + "return nil"
endif
DEFINE WINDOW oWnd TITLE "Scripts" MENU BuildMenu()
DEFINE BUTTONBAR oBar OF oWnd SIZE 80, 80 2007
DEFINE BUTTON OF oBar PROMPT "New" FILE "..\bitmaps\alphabmp\plus.bmp" TOOLTIP "New"
DEFINE BUTTON OF oBar PROMPT "Run" FILE "..\bitmaps\alphabmp\task.bmp" TOOLTIP "Run" ACTION Execute()
DEFINE BUTTON OF oBar PROMPT "Exit" FILE "..\bitmaps\32x32\quit.bmp" TOOLTIP "Exit" ;
ACTION If( MsgYesNo( "Do you want to end ?" ), oWnd:End(),)
@ 5.8, 0 XBROWSE oBrw OF oWnd SIZE 450, 500 ;
FIELDS Scripts->Name, Scripts->Descript ;
HEADERS "Name", "Description" CELL LINES
oBrw:CreateFromCode()
DEFINE FONT oFont NAME "Courier New" SIZE 0, -14
@ 6.3, 57 GET oMemo VAR Scripts->Code MEMO OF oWnd SIZE 500, 500 FONT oFont
@ 0, 450 SPLITTER oSplit ;
VERTICAL _3DLOOK ;
PREVIOUS CONTROLS oBrw ;
HINDS CONTROLS oMemo ;
SIZE 4, 200 PIXEL ;
OF oWnd
oSplit:AdjClient()
DEFINE MSGBAR oMsgBar OF oWnd 2007 PROMPT "Scripting support for your applications"
ACTIVATE WINDOW oWnd MAXIMIZED ;
ON RESIZE oSplit:AdjClient()
return nil
function BuildMenu()
local oMenu
MENU oMenu
MENUITEM "Scripts management"
MENU
MENUITEM "About..." ACTION MsgAbout( "Scripting support for Harbour and FiveWin", "(c) FiveTech Software 2011" )
SEPARATOR
MENUITEM "Exit" ACTION If( MsgYesNo( "Do you want to end ?" ), oWnd:End(),)
ENDMENU
ENDMENU
return oMenu
function Execute()
local oHrb
MemoWrit( "_temp.prg", Scripts->Code )
FReOpen_Stderr( "comp.log", "w" )
oHrb = HB_CompileBuf( HB_ARGV( 0 ), "_temp.prg", "-n", "-Ic:\fwh\include" )
// MsgInfo( MemoRead( "comp.log" ) )
hb_HrbRun( oHrb )
return nil
#pragma BEGINDUMP
#include <stdio.h>
#include <hbapi.h>
HB_FUNC( FREOPEN_STDERR )
{
hb_retnl( ( LONG ) freopen( hb_parc( 1 ), hb_parc( 2 ), stderr ) );
}
#pragma ENDDUMP