// Scripting for Harbour and FiveWin only (not supported on xHarbour)
#include "FiveWin.ch"
#include "Splitter.ch"
#include "xbrowse.ch"
#include "hbclass.ch"
extern TRibbonBar, GetWinVer, hb_dirbase, hb_at, MsgDate, MsgCalc
static oWnd, oResult
//----------------------------------------------------------------//
function ScriptsMain() // Don't use Main() here so you can use it in your scripts!
local oBrw, oBar, oMsgBar, oFont, oMemo, oSplit, oSplit2
local cCode := '#include "C:\FWH1612\INCLUDE\FiveWin.ch"' + CRLF + CRLF + "function Test()" + CRLF + CRLF + ' MsgInfo( "Hello world!" )' + CRLF + CRLF + "return nil"
local cResult
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 := cCode
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" ACTION ( DbAppend(), Scripts->Name := "new script", oBrw:Refresh(), oMemo:SetText( cCode ) )
DEFINE BUTTON OF oBar PROMPT "Run" FILE "..\bitmaps\alphabmp\task.bmp" TOOLTIP "Run" ;
ACTION ( Scripts->Code := oMemo:GetText(), Execute( Scripts->Code ),;
oResult:SetText( If( Empty( cResult := MemoRead( "comp.log" ) ), "ok", cResult ) ) )
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 ;
COLUMNS "Name", "Descript" ;
HEADERS "Name", "Description" CELL LINES FASTEDIT ;
COLSIZES nil, 30 ;
ALIAS "Scripts" ;
ON CHANGE ( oMemo:SetText( Scripts->Code ), oMemo:Refresh() )
WITH OBJECT oBrw
// :nMarqueeStyle = 4
:bClrRowFocus = { || { CLR_BLACK, RGB(185,220,255) } }
:nMarqueeStyle = MARQSTYLE_HIGHLROWMS
:nStretchCol = 2
:nDataLines = 2
:nEditTypes = EDIT_GET
:CreateFromCode()
END
DEFINE FONT oFont NAME "Courier New" SIZE 0, -16
// @ 6.3, 57 GET oMemo VAR Scripts->Code MEMO OF oWnd SIZE 500, 482 FONT oFont
oMemo = TTxtEdit():New( 63, 455, 500, 501, oWnd )
oMemo:SetFont( oFont )
oMemo:SetText( Scripts->Code )
@ 43.9, 57 GET oResult VAR cResult MEMO OF oWnd SIZE 500, 300 FONT oFont
@ 0, 450 SPLITTER oSplit ;
VERTICAL _3DLOOK ;
PREVIOUS CONTROLS oBrw ;
HINDS CONTROLS oMemo, oResult ;
SIZE 4, 200 PIXEL ;
OF oWnd
@ 565, 454 SPLITTER oSplit2 ;
HORIZONTAL _3DLOOK ;
PREVIOUS CONTROLS oMemo ;
HINDS CONTROLS oResult ;
SIZE 500, 4 PIXEL ;
OF oWnd
DEFINE MSGBAR oMsgBar OF oWnd 2007 PROMPT "Scripting support for your applications"
ACTIVATE WINDOW oWnd MAXIMIZED ;
ON RESIZE ( oSplit:AdjLeft(), oSplit2:AdjRight() )
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
//----------------------------------------------------------------//