PiXCL Syntax Example

The Code Writer wizard (written in PiXCL, source provides in the sample code) generates a running skeleton application. Here's the code produced.


{ Filename : a.pxl
Purpose : Demo Code writer
Date : September 29, 2016
Author : SJD, PiXCL Automation Technologies
History:
Version : 10.6 RELEASE
Update :
Date :
Note: this template is used with the 'cre8tapp.pxl' utility which loads it into memory, then
makes changes with string replace commands. Changes to the code in this file requires
corresponding changes to the 'cre8tapp.pxl' code.
--------------------------------------------------------------------------}
Initialize: {only one instance allowed}
UseCoordinates(PIXEL)
Title$ = "Sample PiXCL Application Title"
WinExist(Title$,Res)
If Res = 0 Then Goto One_Instance
Beep
WinSetActive(Title$,Res)
WinShow(Title$,RESTORE,Res)
End
One_Instance:
UseCaption(Title$) // change the title
WinLocate(Title$,1755,261,2202,516,Res)
UseBackground(TRANSPARENT,0,128,255)
WinShow(Title$,NOTOPMOST,Res)
DrawBackGround
DirGet(SourceDir$) // used later for library function calls
AppWindowHandle(Handle,Handle$, PiXCLFlag,Major,Minor)
SetFontQuality(ANTIALIASED)
SysCmdEndAt(Terminate)
// DragAcceptFile(ENABLE,AcceptFile)
// AutoProgressBar(DISABLE)
// InfoMenu(REMOVE)
WaitInput(100)
SetMenu( "&File",IGNORE,
"&New",CreatingFile,
"&Open",OpeningFile,
"&Save",SavingFile,
"Save &All" ,SavingAllFiles ,
SEPARATOR,
"Select &TWAIN Source" , SelectingTWAINSource ,
"&Acquire Image" , ScanningAnImage ,
SEPARATOR,
"E&xit!",Terminate,
ENDPOPUP,
"&View",IGNORE,
"&ToolBar",ViewToolBar,
"&StatusBar",ViewStatusBar,
"T&ransparent",ViewTransparently,
ENDPOPUP,
"&Information",IGNORE,
"&Concept",Concept,
"&Help",ShowAppHelp,
SEPARATOR,
"&About",About,
ENDPOPUP)
GoSub MakeToolbar
ChangeMenuItem( "&ToolBar",CHECK,TBRes)
 
StatusWindow(ENABLE,BOTTOM,2,200,-1,0,0)
DrawStatusWinText(0, "Ready")
ChangeMenuItem( "&StatusBar",CHECK,SBRes)
ViewTransparent = 0
 
Wait_for_Input:
WaitInput()
 
Terminate:
/* Put in any special commands here that have to executed when the app exits. */
End
 
Concept:
MessageBox(OK,1,INFORMATION,
"This is a skeleton of a PiXCL application. You could briefly
describe your application's function here, or provide some
basic help information." ,
"PiXCL Skeleton Concept",Res)
Goto Wait_for_Input
 
ShowAppHelp:
/* An application Help file usually has the same name as the application. */
HelpFile$ = SourceDir$ + "\a.hlp"
Winhelp(HelpFile$,CONTENTS,"")
Goto Wait_for_Input
 
About:
AboutUser( "Sample PiXCL Application Title" , // or substitute Title$
"Two lines of text goes here e.g. Application function." ,
"Four Lines of additional information goes here, perhaps contact information and Web addresses" )
Goto Wait_for_Input
 
ViewToolBar:
GetMenuStatus("&ToolBar",CHECKED,Res)
If Res = 0
GoSub MakeToolbar
ChangeMenuItem( "&ToolBar",CHECK,Res)
Else
Toolbar()
ChangeMenuItem( "&ToolBar",UNCHECK,Res)
Endif
Goto Wait_for_Input
 
ViewStatusBar:
GetMenuStatus( "&StatusBar",CHECKED, Res)
If Res = 0
StatusWindow(ENABLE,BOTTOM,2,200,-1,0,0)
DrawStatusWinText(0, "Ready")
ChangeMenuItem( "&StatusBar",CHECK,Res)
Else
StatusWindow(DISABLE,BOTTOM,2,200,-1,0,0)
ChangeMenuItem( "&StatusBar",UNCHECK,Res)
Endif
Goto Wait_for_Input
 
ViewTransparently:
If ViewTransparent = 0
WinShowLayered(Title$,0,0,0, 144, ALPHA,Res)
ViewTransparent = 1
ChangeMenuItem( "T&ransparent",CHECK,Res)
Else
WinShowLayered(Title$,0,0,0, 144, UNLAYER,Res)
ViewTransparent = 0
ChangeMenuItem( "T&ransparent",UNCHECK,Res)
Endif
Goto Wait_for_Input
 
SelectingTWAINSource:
WaitInput(1)
TWAIN_SelectSource(0, Result)
Goto Wait_for_Input
 
ScanningAnImage: // acquire an image and display it in a window
WaitInput(1)
ScannerImage$ = SourceDir$ + "\scanned_image.bmp"
TWAIN_AcquireNative(ScannerImage$,ANYTYPE,Res)
WinGetClientRect(Title$,cx1,cy1,cx2,cy2) cy1 += 40 cy2 -= 30
If bmwID = 0
DrawBitmapWindow(cx1,cy1,cx2,cy2,ScannerImage$, CAPTION_SIZE,bmwID)
Else
ChangeBMWImage(bmwID,ScannerImage$, Res)
Endif
Goto Wait_for_Input
 
CreatingFile:
WaitInput(1)
/* TODO: add file handling here */
MessageBox(OK,1,INFORMATION, "No operations coded for this button." ,
"Creating File" ,Res)
Goto Wait_for_Input
 
OpeningFile:
WaitInput(1)
/* TODO: add file handling here */
MessageBox(OK,1,INFORMATION, "No operations coded for this button." ,
"Opening File" ,Res)
Goto Wait_for_Input
 
SavingFile:
WaitInput(1)
/* TODO: add file handling here */
MessageBox(OK,1,INFORMATION, "No operations coded for this button." ,
"Saving File" ,Res)
Goto Wait_for_Input
 
SavingAllFiles:
WaitInput(1)
/* TODO: add file handling here */
MessageBox(OK,1,INFORMATION, "No operations coded for this button." ,
"Saving All Files" ,Res)
Goto Wait_for_Input
 
PrintingFile:
WaitInput(1)
/* TODO: add file handling here */
MessageBox(OK,1,INFORMATION, "No operations coded for this button." ,
"Printing File" ,Res)
Goto Wait_for_Input
 
AcceptFile:
GetDragList(FileList$)
/* TODO: add file list handling here, or delete this whole label handler */
Goto Wait_for_Input
 
/*--- Style Suggestion: place all subroutines at the end of the script. */
MakeToolbar: // subroutine
Toolbar(RAISED, PXL_LARGE,
NULL, NULL, SEPARATOR, "" , Wait_for_Input ,
SELECTSOURCE, ENABLED, STD, "Select TWAIN Source" , SelectingTWAINSource ,
SCANNER_1, ENABLED, STD, "Scanner Operation" , ScanningAnImage ,
PXL_NEW, ENABLED, STD, "FileNew" , CreatingFile ,
PXL_OPEN, ENABLED, STD, "FileOpen" , OpeningFile ,
PXL_SAVE, ENABLED, STD, "FileSave" , SavingFile ,
SAVEALL, ENABLED, STD, "Save All" , SavingAllFiles ,
PXL_PRINT, ENABLED, STD, "PrintFile" , PrintingFile ,
NULL, NULL, SEPARATOR, "" , Wait_for_Input ,
HELPINFO, ENABLED, STD, "Show Help" ,ShowAppHelp )
Return

This code produces this window.


Copyright 2011-2019 PiXCL Automation Technologies Inc. All Rights Reserved.