' ********************************************************************************
' Program:     gemsdemo                               Version: 1.1.0.0 - 14/1/2005
'
' Produced By: I O Systech Limited        Author: Neil Parrish
' Website:     www.iosystech.co.uk        Email:  enquiries@iosystech.co.uk
' Phone:       +44 (0)7041 420182         Fax:    +44 (0)8707 064666
'              +44 (0)1784 432058
'
' Purpose:     Demonstrates the features of GEMS (Graphical Elements Made for
'              Smartware).
' Parameters:  None.
' Requires:    GEMS.DLL & GEMS.RF3 - provided with this project.
'              SmartWare - version 2.65b or higher (uses DLL commands).
'              SmartWare screen resolution of 60x20 or greater.
' Usage:       Run this project and select the required options.
'
' Notes:
' Keep this project in the same directory/folder as the DLL & GEMS.RF3 - make
' this the current directory in the database part of SmartWare (TOOLS-DIRECTORY-
' NEW-DIRECTORY) and then run this project.
'
' The DLL supplied is a demo version so the wording 'I O SYSTECH DEMO' is included
' in all features - this is not present in the full version.
'
' Demo versions prior to v1 did not include full error handling routines. This
' version does although they are only used explicitly in the _TextViewer()
' function. Correct handling of cancel buttons has also been added.
'
' This code may be used and distributed free of charge.
' ********************************************************************************
'
' *** FUNCTIONS
EXTERNAL _GEMS_Load() _GEMS_Unload()
EXTERNAL _GEMS_ResetStdParam() _GEMS_ResetCtrlParam()
EXTERNAL _GEMS_ProgressOn() _GEMS_ProgressMove() _GEMS_ProgressTextMove() _GEMS_ProgressOff()
EXTERNAL _GEMS_MessageOn() _GEMS_MessageOff()
EXTERNAL _GEMS_Input()
EXTERNAL _GEMS_Text() _GEMS_TextOn() _GEMS_TextOff()
EXTERNAL _GEMS_AnimateOn() _GEMS_AnimateOff()
EXTERNAL _GEMS_ScrollBar() _GEMS_ScrollBarEx()
EXTERNAL _GEMS_TrackBar() _GEMS_TrackBarEx()
EXTERNAL _GEMS_Colour() _GEMS_Color()
EXTERNAL _GEMS_Date()
EXTERNAL _GEMS_Time()
EXTERNAL _GEMS_ListBox()
EXTERNAL _GEMS_CheckList()
EXTERNAL _GEMS_Display_Message()
EXTERNAL _GEMS_Get_Choice()
EXTERNAL _GEMS_WinDialog()
EXTERNAL _GEMS_SetSWTitle()
EXTERNAL _GEMS_SWCmndLine()
EXTERNAL _GEMS_GetDir()

GLOBAL _reset() _display(1)
GLOBAL _intro1() _intro2() _intro3() _intro4() _intro5() _intro6()
GLOBAL _options() _subopt()
GLOBAL _ProgressBar() _ProgressText() _MessageBox() _MessageText()
GLOBAL _ColourPicker() _ColourText() _TrackBar() _TrackText()
GLOBAL _Animation() _AnimationText() _TextViewer() _TextVText()
GLOBAL _InputBox() _InputText() _ListBox() _ListText()
GLOBAL _CheckList() _CheckText() _Datepicker() _DateText()
GLOBAL _TimePicker() _TimeText() _ScrollBar() _ScrollText()
GLOBAL _DisplayMessage() _DMText() _GetChoice() _GCText()
GLOBAL _params1() _params2() _params3() _params4() _params4Text() _params5()
GLOBAL _SWiP1() _SWiP2() _SWiP3() _SWiP4() _SWiP5()
GLOBAL _general1() _general2()
GLOBAL _exit()
GLOBAL _IncharClear()

' *** VARIABLES
PUBLIC #GEMS_fg #GEMS_bg #GEMS_bounds #GEMS_fontsize #GEMS_fwidth #GEMS_fheight
PUBLIC #GEMS_fpercentage #GEMS_ctrl_fg #GEMS_ctrl_bg #GEMS_ctrl_fontsize
PUBLIC #GEMS_Cancel #GEMS_SWError35 #GEMS_Error #GEMS_sel_bg #GEMS_sel_fg
PUBLIC #GEMS_GCSepChar
PUBLIC $GEMS_DLLPath $GEMS_fposition $GEMS_SelectedOptions $GEMS_SortedOptions
PUBLIC $GEMS_RADFuncTitle

GLOBAL #fg #bg #col[15,2] #offx #offy #option #subopt
GLOBAL $text[15]


MAIN
 LOCAL $s
	IF SCRWIDTH < 60 OR SCRHEIGHT < 20
		MESSAGE "ERROR ! - SCREEN SIZE MUST BE 60x20 OR GREATER"
		EXIT
	END IF
	LOCK SYSTEM PUBLIC
	LOAD "GEMS" IN-MEMORY

' Set $GEMS_DllPath if the DLL is not in the current SmartWare datapath, or Windows, System etc.
'	$GEMS_DLLPath = "Path to the DLL"

' Optionally pre-load the DLL if you want to during initialisation. Pre-loading means
' the very slight delay in loading is part of initialisation, and not the first function.
' All the functions will load it anyway, if it has not yet been loaded.
	_GEMS_Load()

	#fg = 11
	#bg = 0
	#offx = int((scrwidth/2) - 30)
	#offy = int(((scrheight-4)/2) - 8)

	IF _intro1() = {esc}
		JUMP exitpage
	END IF
	IF _intro2() = {esc}
		JUMP exitpage
	END IF
	IF _intro3() = {esc}
		JUMP exitpage
	END IF
	IF _intro4() = {esc}
		JUMP exitpage
	END IF
	IF _intro5() = {esc}
		JUMP exitpage
	END IF
	IF _intro6() = {esc}
		JUMP exitpage
	END IF

LABEL selectoption
	_options()
	$s = "1_All_14 2_One_function 3_Options,_Parameters_&_Windows_API_Functions 4_I_O_Systech_SmartWare_Products(SWiP) 5_I_O_Systech_Products_&_Services"
	SCREEN PROMPT #offy+8 #offx+4 #offy+14 #offx+56 #fg-1 #bg $s #option "Select an option"
	CASE #option
	WHEN 1
		IF _ProgressBar() = {esc}
			JUMP selectoption
		END IF
		IF _MessageBox() = {esc}
			JUMP selectoption
		END IF
		IF _ColourPicker() = {esc}
			JUMP selectoption
		END IF
		IF _TrackBar() = {esc}
			JUMP selectoption
		END IF
		IF _Animation() = {esc}
			JUMP selectoption
		END IF
		IF _TextViewer() = {esc}
			JUMP selectoption
		END IF
		IF _InputBox() = {esc}
			JUMP selectoption
		END IF
		IF _ListBox() = {esc}
			JUMP selectoption
		END IF
		IF _CheckList() = {esc}
			JUMP selectoption
		END IF
		IF _DatePicker() = {esc}
			JUMP selectoption
		END IF
		IF _TimePicker() = {esc}
			JUMP selectoption
		END IF
		IF _ScrollBar() = {esc}
			JUMP selectoption
		END IF
		IF _DisplayMessage() = {esc}
			JUMP selectoption
		END IF
		IF _GetChoice() = {esc}
			JUMP selectoption
		END IF
	WHEN 2
LABEL part2
		_subopt()
		$s = "Progress_Bar Message_Box Colour_Picker Track_Bar Animation Text_Viewer Input_Box List_Box Check_List Date_Picker/Time_Picker Scroll_Bar Display_Message/Get_Choice Windows_API_Functions"
		SCREEN PROMPT #offy #offx+27 #offy+15 #offx+60 #fg-1 #bg $s #subopt "Select a feature"
		CASE #subopt
		WHEN 1
			_ProgressBar()
		WHEN 2
			_MessageBox()
		WHEN 3
			_ColourPicker()
		WHEN 4
			_TrackBar()
		WHEN 5
			_Animation()
		WHEN 6
			_TextViewer()
		WHEN 7
			_InputBox()
		WHEN 8
			_ListBox()
		WHEN 9
			_CheckList()
		WHEN 10
			IF _DatePicker() <> {esc}
				_TimePicker()
			END IF
		WHEN 11
			_ScrollBar()
		WHEN 12
			IF _DisplayMessage() <> {esc}
				_GetChoice()
			END IF
		WHEN 13
			IF _params4() <> {esc}
				_params5()
			END IF
		OTHERWISE
			JUMP selectoption
		END CASE
		JUMP part2
	WHEN 3   ' parameters and options
		IF _params1() = {esc}
			JUMP selectoption
		END IF
		IF _params2() = {esc}
			JUMP selectoption
		END IF
		IF _params3() = {esc}
			JUMP selectoption
		END IF
		IF _params4() = {esc}
			JUMP selectoption
		END IF
		IF _params5() = {esc}
			JUMP selectoption
		END IF
	WHEN 4   'I O Systech SmartWare products
		IF _SWiP1() = {esc}
			JUMP selectoption
		END IF
		IF _SWiP2() = {esc}
			JUMP selectoption
		END IF
		IF _SWiP3() = {esc}
			JUMP selectoption
		END IF
		IF _SWiP4() = {esc}
			JUMP selectoption
		END IF
		IF _SWiP5() = {esc}
			JUMP selectoption
		END IF
	WHEN 5   'I O Systech products & services
		IF _general1() = {esc}
			JUMP selectoption
		END IF
		IF _general2() = {esc}
			JUMP selectoption
		END IF
	OTHERWISE
		JUMP exitpage
	END CASE
	JUMP selectoption

LABEL exitpage
	_exit()

' DLL will be unloaded when SmartWare closes but you can do it yourself if you want to.
	_GEMS_Unload()
	UNLOAD "GEMS"
END MAIN

FUNCTION _reset()
 LOCAL #i
	FOR #i = 1 to 15
		#col[#i,1] = #fg
		#col[#i,2] = #bg
		$text[#i] = ""
	END FOR
END FUNCTION

FUNCTION _display(#mode)
 LOCAL #i
	SCREEN CLEAR BOX 1 1 scrheight-4 scrwidth #fg #bg NO-BORDER
	FOR #i = 1 to 15
		SCREEN PRINT (#offy + #i) (#offx) #col[#i,1] #col[#i,2] $text[#i]
	END FOR
	IF #mode
		RETURN _IncharClear()
	ELSE
		RETURN 0
	END IF
END FUNCTION

FUNCTION _intro1()
	_reset()
	$text[1]  = "Welcome to                                   (Demo v1.1.0.0)"
	$text[2]  = "               GGG    EEEEE  M   M   SSS"
	$text[3]  = "              G       E      MM MM  S"
	$text[4]  = "              G  GGG  EEE    M M M   SSS"
	$text[5]  = "              G   G   E      M   M      S"
	$text[6]  = "               GGG    EEEEE  M   M   SSS"
	$text[7]  = ""
	$text[8]  = "     GEMS - Graphical Elements Made for Smartware"
	$text[9]  = "by"
	$text[10] = "        I O Systech Ltd - www.iosystech.co.uk"
	$text[11] = ""
	$text[12] = "The easy way to improve the usability and appearance of your"
	$text[13] = "SmartWare applications with Windows functionality."
	$text[14] = ""
	$text[15] = "        Esc to Exit - Any other key to continue"
	#col[2,1] = 10
	#col[3,1] = 10
	#col[4,1] = 10
	#col[5,1] = 10
	#col[6,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _intro2()
	_reset()
	$text[1]  = "What Windows functionality is in GEMS ?"
	$text[2]  = ""
	$text[3]  = "The 14 graphical elements included are;"
	$text[4]  = "     Progress Bar                  Input Box"
	$text[5]  = "     List Box                      Message Box"
	$text[6]  = "     Track Bar                     Scroll Bar"
	$text[7]  = "     Date Picker                   Check List"
	$text[8]  = "     Colour Picker                 Text Viewer"
	$text[9]  = "     Animation                     Time Picker"
	$text[10] = "     Display Message               Get Choice"
	$text[11] = "As well as function specific parameters, they may all be"
	$text[12] = "given various font sizes, colours, size and position."
	$text[13] = "Windows API based functions, Windows dialog, email, website,"
	$text[14] = "about box, etc. are shown in the options part of the demo."
	$text[15] = "        Esc to Exit - Any other key to continue"
	#col[1,1] = 10
	#col[4,1] = 10
	#col[5,1] = 10
	#col[6,1] = 10
	#col[7,1] = 10
	#col[8,1] = 10
	#col[9,1] = 10
	#col[10,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _intro3()
	_reset()
	$text[1]  = "What will this demonstration show me ?"
	$text[2]  = ""
	$text[3]  = "All 14 GEMS elements are demonstrated with some options"
	$text[4]  = "shown & others explained in text. This is a demo so all of"
	$text[5]  = "the examples include the 'I O SYSTECH DEMO' wording."
	$text[6]  = ""
	$text[7]  = "The options & parameters part explains the flexibility of"
	$text[8]  = "GEMS via variables & shows the Windows API based functions."
	$text[9]  = ""
	$text[10] = "The GEMSDriver Windows exe is included with the demo. Run it"
	$text[11] = "to try out the options for most GEMS elements. The only"
	$text[12] = "limitation is the bounds parameter, options 1-5 are all the"
	$text[13] = "same, because they relate to parts of the SmartWare window."
	$text[14] = ""
	$text[15] = "        Esc to Exit - Any other key to continue"
	#col[1,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _intro4()
	_reset()
	$text[1]  = "How easy is GEMS to use ?"
	$text[2]  = ""
	$text[3]  = "GEMS consists of a Windows DLL and a SmartWare library. The"
	$text[4]  = "DLL can be installed wherever you like (you may need to set"
	$text[5]  = "a path variable), the library loaded and functions declared"
	$text[6]  = "as externals. Each option is just a single line away. You"
	$text[7]  = "can use the defaults or change the colours, position, size,"
	$text[8]  = "font size, etc. via variables."
	$text[9]  = ""
	$text[10] = "The source to this project is included, GEMSDEMO.PF3, to"
	$text[11] = "show how easy it is to use GEMS. The project is rather large"
	$text[12] = "due to all the text displayed but you can still see the"
	$text[13] = "single line _GEMS... function calls and variable setting."
	$text[14] = ""
	$text[15] = "        Esc to Exit - Any other key to continue"
	#col[1,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _intro5()
	_reset()
	$text[1]  = "How much does GEMS cost ?"
	$text[2]  = ""
	$text[3]  = "UK price for GEMS is 85 pounds, (Pro version, with source"
	$text[4]  = "code, 195). US dollar price is 135 (Pro 310). Prices are per"
	$text[5]  = "developer, volume discounts available. Distribution to"
	$text[6]  = "external clients requires a site licence, costing 15 pounds"
	$text[7]  = "for the first user + 3 pounds per additional user at each"
	$text[8]  = "site (maximum of 65 pounds/site). In US dollars - 25, 5 &"
	$text[9]  = "max. 105. Website has full details - inc. developer bundles."
	$text[10] = ""
	$text[11] = "When can I get a copy of GEMS ?"
	$text[12] = ""
	$text[13] = "GEMS is available now"
	$text[14] = ""
	$text[15] = "        Esc to Exit - Any other key to continue"
	#col[1,1] = 10
	#col[11,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _intro6()
	_reset()
	$text[1]  = "Do I O Systech want my feedback and comments ?"
	$text[2]  = ""
	$text[3]  = "Yes we do - more the better ? We intend to make minor"
	$text[4]  = "changes available via (free emailed) maintenance releases."
	$text[5]  = "New versions of GEMS with extra functions will be produced"
	$text[6]  = "if there is sufficient demand."
	$text[7]  = ""
	$text[8]  = "Can I try the demo GEMS library and code with my projects ?"
	$text[9]  = ""
	$text[10] = "Yes you can but be aware that the versions you have include"
	$text[11] = "the 'I O SYSTECH DEMO' text, which cannot be removed. If"
	$text[12] = "you wish to do some thorough testing before purchasing"
	$text[13] = "we can supply a copy of the documentation on request."
	$text[14] = ""
	$text[15] = "        Esc to Exit - Any other key to continue"
	#col[1,1] = 10
	#col[8,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _options()
	_reset()
	$text[1]  = "                 GEMS Demonstration - Main Menu"
	$text[2]  = "The demonstration is in 5 parts. The first takes you through"
	$text[3]  = "all 14 GEMS features. Part 2 uses the same examples but you"
	$text[4]  = "can select the ones to see. Part 3 shows control parameters"
	$text[5]  = "& options and Windows API functions. Part 4 gives details of"
	$text[6]  = "the SWiP product for SmartWare. The final part explains more"
	$text[7]  = "about I O Systech and their products & services."
	$text[8]  = ""
	$text[9]  = ""
	$text[10] = ""
	$text[11] = ""
	$text[12] = ""
	$text[13] = ""
	$text[14] = ""
	$text[15] = "                       Esc to Exit"
	#col[1,1] = 10
	#col[15,1] = 14
	RETURN _display(0)
END FUNCTION

FUNCTION _subopt()
	_reset()
	$text[1]  = " GEMS DEMO - Part 2 Menu"
	$text[2]  = ""
	$text[3]  = "Select a GEMS element or"
	$text[4]  = "the API functions."
	$text[5]  = ""
	$text[6]  = "The examples are the same"
	$text[7]  = "as shown in other sections"
	$text[8]  = "of this demonstration."
	$text[9]  = ""
	$text[10] = "N.B. GEMS Variables used"
	$text[11] = "to modify functions are"
	$text[12] = "shown here & explained in"
	$text[13] = "detail in the 'Options &"
	$text[14] = "Parameters' section."
	$text[15] = "  Esc for the Main Menu"
	#col[1,1] = 10
	#col[15,1] = 14
	RETURN _display(0)
END FUNCTION

FUNCTION _ProgressBar()
	IF _ProgressText() = {esc}
		RETURN {esc}
	END IF
	_GEMS_ProgressOn("Watch the bar move after each key press")
	IF _IncharClear() = {esc}
		_GEMS_ProgressOff()
		RETURN {esc}
	END IF
	_GEMS_ProgressMove(15)
	IF _IncharClear() = {esc}
		_GEMS_ProgressOff()
		RETURN {esc}
	END IF
	_GEMS_ProgressTextMove("The text can change too !!",60)
	IF _IncharClear() = {esc}
		_GEMS_ProgressOff()
		RETURN {esc}
	END IF
	_GEMS_ProgressMove(100)
	IF _IncharClear() = {esc}
		_GEMS_ProgressOff()
		RETURN {esc}
	END IF
	_GEMS_ProgressOff()
END FUNCTION

FUNCTION _ProgressText()
	_reset()
	$text[1]  = "                  GEMS DEMO - Progress Bar"
	$text[2]  = ""
	$text[3]  = "Use the progress bar to keep your users informed of the"
	$text[4]  = "current status of an operation."
	$text[5]  = ""
	$text[6]  = "  Your next key press will display the bar, centred."
	$text[7]  = "  The next one will move the bar to 15%"
	$text[8]  = "  Next key press takes it to 60% & changes the text"
	$text[9]  = "  Another key takes it to 100%"
	$text[10] = "  Final key press removes the progress bar"
	$text[11] = ""
	$text[12] = "In your applications it will be code reaching milestones"
	$text[13] = "that will control the bar and not just key presses - or you"
	$text[14] = "can link it to your database queries."
	$text[15] = "    Esc for the Menu - Any other key for the progress bar"
	#col[1,1] = 10
	#col[6,1] = 10
	#col[7,1] = 10
	#col[8,1] = 10
	#col[9,1] = 10
	#col[10,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _MessageBox()
	IF _MessageText() = {esc}
		RETURN {esc}
	END IF
	_GEMS_MessageOn("This a GEMS message box !","Press any key to clear it.","Display this to your user -","and clear it once your code has finished")
	IF _IncharClear() = {esc}
		_GEMS_MessageOff()
		RETURN {esc}
	END IF
	_GEMS_MessageOff()
	IF _IncharClear() = {esc}
		RETURN {esc}
	END IF
	#GEMS_fontsize = 30
	#GEMS_fg = 10
	#GEMS_bg = 0
	_GEMS_MessageOn("Large text & colour anyone ?","Press any key.","","")
	_GEMS_ResetStdParam()
	IF _IncharClear() = {esc}
		_GEMS_MessageOff()
		RETURN {esc}
	END IF
	_GEMS_MessageOff()
	IF _IncharClear() = {esc}
		RETURN {esc}
	END IF
	#GEMS_fontsize = 20
	#GEMS_bounds = 0
	$GEMS_fposition = "MT"
	#GEMS_fpercentage = 100
	#GEMS_fg = 12
	_GEMS_MessageOn("Finally make it fill the top of the desktop","Press any key.","","")
	_GEMS_ResetStdParam()
	IF _IncharClear() = {esc}
		_GEMS_MessageOff()
		RETURN {esc}
	END IF
	_GEMS_MessageOff()
END FUNCTION

FUNCTION _MessageText()
	_reset()
	$text[1]  = "                  GEMS DEMO - Message Box"
	$text[2]  = ""
	$text[3]  = "Use the message box to tell your users what is happening."
	$text[4]  = "It is easy to emphasise with large fonts and colours."
	$text[5]  = ""
	$text[6]  = "  Keep pressing the keys to see and clear 3 examples"
	$text[7]  = "  First is default colours, size and position"
	$text[8]  = "  Second is 30pt font size with colour & only uses 2 lines "
	$text[9]  = "  Final one positions & sizes it across the screen top"
	$text[10] = ""
	$text[11] = "As with the progress bar it will be your code reaching set"
	$text[12] = "points that closes the box and not just key presses."
	$text[13] = ""
	$text[14] = ""
	$text[15] = "    Esc for the Menu - Any other key for the messages"
	#col[1,1] = 10
	#col[6,1] = 10
	#col[7,1] = 10
	#col[8,1] = 10
	#col[9,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _ColourPicker()
'Note that the first call is to UK spelt _GEMS_Colour the second to US _GEMS_Color.
 LOCAL #temp
	IF _ColourText() = {esc}
		RETURN {esc}
	END IF
	#temp = _GEMS_Colour("This is a colour picker","Select the colours you want",0,12,0)
	IF #GEMS_Cancel
		$text[9] =  "        You cancelled - default colours                     "
	ELSE
		$text[9] =  "          You selected these colours                        "
	END IF
	#col[9,1] = #GEMS_sel_fg
	#col[9,2] = #GEMS_sel_bg
	$text[10] = "  Next one - no caption, 8x2 grid and only wants foreground."
	#col[10,1] = 10
	IF _display(1) = {esc}
		RETURN {esc}
	END IF
	#temp = _GEMS_Color("","Select the foreground colour you want",5,9,0)
	IF #GEMS_Cancel
		$text[11] = "       You cancelled - default foreground colour            "
	ELSE
		$text[11] = "          You selected this foreground colour               "
	END IF
	#col[11,1] = #GEMS_sel_fg
	$text[15] = "     Esc for the Menu - Any other key to continue"
	IF INT(#temp/16) = 0
		#col[11,2] = 15
	END IF
	RETURN _display(1)
END FUNCTION

FUNCTION _ColourText()
	_reset()
	$text[1]  = "                GEMS DEMO - Colour Picker"
	$text[2]  = ""
	$text[3]  = "Let your users select colours the easy way. Can be used for"
	$text[4]  = "either foreground, background or both. Left click to select"
	$text[5]  = "foreground, right click for background. The function is"
	$text[6]  = "implemented with UK and US spellings of colo(u)r."
	$text[7]  = ""
	$text[8]  = "  Your next key press will bring up the colour picker"
	$text[9]  = ""
	$text[10] = ""
	$text[11] = ""
	$text[12] = ""
	$text[13] = "Note SmartWare operation is stopped until you OK or Cancel"
	$text[14] = "the colour picker."
	$text[15] = "   Esc for the Menu - Any other key for the colour picker"
	#col[1,1] = 10
	#col[8,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _TrackBar()
 LOCAL #temp
	IF _TrackText() = {esc}
		RETURN {esc}
	END IF
	#temp = _GEMS_TrackBar("This is a track bar","Select the value you want",0,10,5)
	IF #GEMS_Cancel
		$text[8] = "      You cancelled:" & STR(#temp) & "(initial value)"
	ELSE
		$text[8] = "      You selected:" & STR(#temp)
	END IF
	$text[9] = "  Next has a wider range, no title bar and moves by 50 & 100"
	#col[9,1] = 10
	IF _display(1) = {esc}
		RETURN {esc}
	END IF
	#temp = _GEMS_TrackBarEx("","Select the value you want",-1000,1000,-200,50,100)
	IF #GEMS_Cancel
		$text[10] = "      You cancelled:" & STR(#temp) & "(initial value)"
	ELSE
		$text[10] = "      You selected:" & STR(#temp)
	END IF
	$text[15] = "     Esc for the Menu - Any other key to continue"
	RETURN _display(1)
END FUNCTION

FUNCTION _TrackText()
	_reset()
	$text[1]  = "                GEMS DEMO - Track Bar"
	$text[2]  = ""
	$text[3]  = "Here is a Windows standard way to select a numeric value."
	$text[4]  = "You specify the min, max and starting values - the function"
	$text[5]  = "returns the users selection."
	$text[6]  = ""
	$text[7]  = "  Your next key press will bring up the track bar"
	$text[8]  = ""
	$text[9]  = ""
	$text[10] = ""
	$text[11] = ""
	$text[12] = "Note SmartWare operation is stopped until you OK or Cancel"
	$text[13] = "the track bar. See the scroll bar for similar examples."
	$text[14] = ""
	$text[15] = "   Esc for the Menu - Any other key for the track bar"
	#col[1,1] = 10
	#col[7,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _Animation()
	IF _AnimationText() = {esc}
		RETURN {esc}
	END IF
	_GEMS_AnimateOn(4,"Copying files animation - look familiar ?")
	IF _IncharClear() = {esc}
		_GEMS_AnimateOff()
		RETURN {esc}
	END IF
	_GEMS_AnimateOff()
	$text[9]  = "  The next key starts a find folder animation."
	$text[10] = "  Another key press stops it."
	#col[9,1] = 10
	#col[10,1] = 10
	IF _display(1) = {esc}
		RETURN {esc}
	END IF
	_GEMS_AnimateOn(1,"FindFolder animation")
	IF _IncharClear() = {esc}
		_GEMS_AnimateOff()
		RETURN {esc}
	END IF
	_GEMS_AnimateOff()
END FUNCTION

FUNCTION _AnimationText()
	_reset()
	$text[1]  = "                GEMS DEMO - Animation"
	$text[2]  = ""
	$text[3]  = "You can now use 8 standard Windows animations when copying"
	$text[4]  = "files, searching etc. to keep your user notified."
	$text[5]  = ""
	$text[6]  = "  Press a key to start a file copying animation."
	$text[7]  = "  Press again to stop it."
	$text[8]  = ""
	$text[9]  = ""
	$text[10] = ""
	$text[11] = ""
	$text[12] = ""
	$text[13] = ""
	$text[14] = ""
	$text[15] = "   Esc for the Menu - Any other key for animations"
	#col[1,1] = 10
	#col[6,1] = 10
	#col[7,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _TextViewer()
 LOCAL $path $file
	#GEMS_SWError35 = 0
	$path = "C:\"
	$file = "autoexec.bat"
	IF _TextVText() = {esc}
		RETURN {esc}
	END IF
'Ex.1 - Mode 35 is maximised with the text Pen with an A icon.
	_GEMS_Text("Here is the"&$file&"file",$path|$file,35)
	IF #GEMS_Error = 2802  'no such file
		$path = PATH(DATAPATH)
		$file = "gemsdemo.pf3"
		_GEMS_Text("Here is the"&$file&"file",$path|$file,35)
		IF #GEMS_Error = 2802  'no such file
			$file = GROUP(GETFNAMES($path|"*.txt",1),1)
			IF $file = ""
				$path = "C:\"
				$file = GROUP(GETFNAMES($path|"*.txt",1),1)
				IF $file = ""
					_GEMS_WinDialog("No suitable text files found for the examples","Text Viewer examples",16)
					#GEMS_SWError35 = 1
					RETURN {esc}
				END IF
			END IF
			_GEMS_Text("Here is the"&$file&"file",$path|$file,35)
		END IF
	END IF
	#GEMS_SWError35 = 1
'Ex.2 - Mode 199 = user cannot close, minimised, yellow ? icon
	_GEMS_TextOn("Help is at hand",$path|$file,199)
	$text[9]  = "  Example 2 has started - it's minimised on the task bar."
	$text[10] = "  This is the background mode - we have also removed the"
	$text[11] = "  close option (optional). Press a key to close it."
	$text[13] = "  N.B. Text files ("|$file|") used here, not RTF files."
	$text[15] = "        Esc for the Menu - Any other key to continue"
	IF _display(1) = {esc}
		_GEMS_TextOff()
		RETURN {esc}
	END IF
	_GEMS_TextOff()
	$text[9]  = "  Example 3 is similar to 1 with 'normal' window size and"
	$text[10] = "  coloured text. SmartWare is stopped until the text closes."
	$text[11] = "  Notice the third different icon. Press a key for viewer 3."
	IF _display(1) = {esc}
		RETURN {esc}
	END IF
	#GEMS_fg = 1
	#GEMS_bg = 7
'Ex.3 - Mode 1 or normal size and GEMS icon.
	_GEMS_Text("Normal window size & colour -"&$file&"again",$path|$file,1)
	_GEMS_ResetStdParam()
END FUNCTION

FUNCTION _TextVText()
	_reset()
	$text[1]  = "                  GEMS DEMO - Text Viewer"
	$text[2]  = ""
	$text[3]  = "This enables the viewing of txt or rtf files. This could be"
	$text[4]  = "used to display important notices, operating procedures,"
	$text[5]  = "help etc. With RTF files you can use different fonts, sizes"
	$text[6]  = "or colours to emphasise text. The text viewer has two modes,"
	$text[7]  = "either run in the foreground or background."
	$text[8]  = ""
	$text[9]  = "  Your next key press will start example 1 of 3. Maximised"
	$text[10] = "  in foreground mode - SmartWare stopped until text closed."
	$text[11] = ""
	$text[12] = ""
	$text[13] = "  N.B. Text files (Autoexec.bat?) used here, not RTF files."
	$text[14] = ""
	$text[15] = "   Esc for the Menu - Any other key for the text viewer"
	#col[1,1] = 10
	#col[9,1] = 10
	#col[10,1] = 10
	#col[11,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _InputBox()
 LOCAL $temp
	IF _InputText() = {esc}
		RETURN {esc}
	END IF
'mode 0 = any character
	$temp =_GEMS_Input("Here is an input box","Enter up to 20 chars","Start with this",20,"0","")
	IF #GEMS_Cancel
		$text[10] =  "You cancelled:" & $temp & "(initial value)"
	ELSE
		$text[10] =  "You entered:" & $temp
	END IF
	$text[12]  = "  Example 2. Password entry (masked with *), No title bar."
	IF _display(1) = {esc}
		RETURN {esc}
	END IF
	$temp =_GEMS_Input("","Enter your password","",0,"2","")
	$text[8]  = "  Example 2. Password entry (masked with *), No title bar."
	IF #GEMS_Cancel
		$text[10] =  "You cancelled:" & $temp & "(no initial value)"
	ELSE
		$text[10] =  LEFT("You entered:" & $temp,60)
		IF LEN($temp) > 47
			$text[11] = "  (N.B. The entered text has been truncated for display.)"
		ELSE
			$text[11] = ""
		END IF
	END IF
	$text[12] = "  Example 3. Only accepts characters ABCabc. Larger fonts."
	IF _display(1) = {esc}
		RETURN {esc}
	END IF
'Increase the fontsize for this example, reset it afterwards
	#GEMS_fontsize = 20
	$temp =_GEMS_Input("GEMS input box - large font","Only accepts A,B,C,a,b or c","",0,"1","ABCabc")
	_GEMS_ResetStdParam()
	$text[8] = "  Example 3. Only accepts characters ABCabc. Larger fonts."
	IF #GEMS_Cancel
		$text[10] =  "You cancelled:" & $temp & "(no initial value)"
	ELSE
		$text[10] =  LEFT("You entered:" & $temp,60)
		IF LEN($temp) > 47
			$text[11] = "  (N.B. The entered text has been truncated for display.)"
		ELSE
			$text[11] = ""
		END IF
	END IF
	$text[12] = "  Example 4. Numeric entry with up to 2 decimal places."
	IF _display(1) = {esc}
		RETURN {esc}
	END IF
	$temp =_GEMS_Input("GEMS input box","Numeric input (2 decimal places)","",0,"3.2","")
	$text[8] = "  Example 4. Numeric entry with up to 2 decimal places."
	IF #GEMS_Cancel
		$text[10] =  "You cancelled:" & $temp & "(no initial value)"
	ELSE
		$text[10] =  LEFT("You entered:" & $temp,60)
		IF LEN($temp) > 47
			$text[11] = "  (N.B. The entered text has been truncated for display.)"
		ELSE
			$text[11] = ""
		END IF
	END IF
	$text[12] = "  Example 5. Forced upper case entry, font sizes & colours."
	IF _display(1) = {esc}
		RETURN {esc}
	END IF
'Set colours and font sizes for this upper case (mode 7) input box.
	#GEMS_fontsize = 10
	#GEMS_fg = 1
	#GEMS_bg = 15
	#GEMS_ctrl_fontsize = 30
	#GEMS_ctrl_fg = 7
	#GEMS_ctrl_bg = 3
	$temp =_GEMS_Input("GEMS input box","Upper case input","TYPE HERE",0,"7","")
	_GEMS_ResetStdParam()
	_GEMS_ResetCtrlParam()
	$text[8] = "  Example 5. Forced upper case entry, font sizes & colours."
	IF #GEMS_Cancel
		$text[10] =  "You cancelled:" & $temp & "(initial value)"
	ELSE
		$text[10] =  LEFT("You entered:" & $temp,60)
		IF LEN($temp) > 47
			$text[11] = "  (N.B. The entered text has been truncated for display.)"
		ELSE
			$text[11] = ""
		END IF
	END IF
	$text[12] = ""
	$text[15] = "        Esc for the Menu - Any other key to continue"
	_display(1)
END FUNCTION

FUNCTION _InputText()
	_reset()
	$text[1]  = "                   GEMS DEMO - Input Box"
	$text[2]  = ""
	$text[3]  = "This is a Windows way to take user input. It has modes for"
	$text[4]  = "any character, numeric, upper, lower, ranges or passwords."
	$text[5]  = "Initial text and maximum length can be specified and the"
	$text[6]  = "colours of both the input and the box can be changed."
	$text[7]  = ""
	$text[8]  = "  Example 1. Any character - maximum length 20."
	$text[9]  = ""
	$text[10] = ""
	$text[11] = ""
	$text[12] = ""
	$text[13] = ""
	$text[14] = ""
	$text[15] = "     Esc for the Menu - Any other key for the input box"
	#col[1,1] = 10
	#col[8,1] = 10
	#col[9,1] = 10
	#col[12,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _ListBox()
 LOCAL $options $temp
	IF _ListText() = {esc}
		RETURN {esc}
	END IF
	$options = "First"|CHR(47)|"Spaces in option 2"|CHR(47)|"No.3"|CHR(47)|"Last choice"
	$temp = _GEMS_ListBox("This is a list box","Select the required item",$options,0,47)
	IF #GEMS_Cancel
		$text[12] = "          You cancelled:" & $temp & "(empty string returned)"
	ELSE
		$temp = "You selected option:" & $temp & "- text:" & $GEMS_SelectedOptions
		IF LEN($temp) > 60
			$temp = LEFT($temp,58)|".."
		ELSE
			$temp = REPEAT(" ",INT((60-LEN($temp))/2))|$temp
		END IF
		$text[12] = $temp
	END IF
	$text[13] = "  Example 2: Multiple selection, single column."
	IF _display(1) = {esc}
		RETURN {esc}
	END IF
'This one allows multilpe selection
	$options = "Communications"|CHR(47)|"Database"|CHR(47)|"Spreadsheet"|CHR(47)|"Word processor"
	$temp = _GEMS_ListBox("List box - Multiple selection","Select the module(s) you use",$options,64,47)
	IF #GEMS_Cancel
		$text[12] = "          You cancelled:" & $temp & "(empty string returned)"
	ELSE
		$temp = "You selected option(s):" & $temp & "- text:" & $GEMS_SelectedOptions
		IF LEN($temp) > 60
			$temp = LEFT($temp,58)|".."
		ELSE
			$temp = REPEAT(" ",INT((60-LEN($temp))/2))|$temp
		END IF
		$text[12] = $temp
	END IF
	$text[13] = " Example 3: Extended multi-selection, columns, size & colour."
	IF _display(1) = {esc}
		RETURN {esc}
	END IF
'Multiple columns and multilpe extended selection (shift and ctrl keys)
	#GEMS_ctrl_fontsize = 20
	#GEMS_ctrl_fg = 10
	#GEMS_ctrl_bg = 0
	$options = "One"|CHR(47)|"Two"|CHR(47)|"Three"|CHR(47)|"Four"|CHR(47)|"Five"|CHR(47)|"Six"
	$temp = _GEMS_ListBox("List box - Extended selection","Select item(s) (shift and ctrl keys)",$options,194,47)
	_GEMS_ResetCtrlParam()
	IF #GEMS_Cancel
		$text[12] = "          You cancelled:" & $temp & "(empty string returned)"
	ELSE
		$temp = "You selected option(s):" & $temp & "- text:" & $GEMS_SelectedOptions
		IF LEN($temp) > 60
			$temp = LEFT($temp,58)|".."
		ELSE
			$temp = REPEAT(" ",INT((60-LEN($temp))/2))|$temp
		END IF
		$text[12] = $temp
	END IF
	$text[13] = ""
	$text[15] = "       Esc for the Menu - Any other key to continue"
	_display(1)
END FUNCTION

FUNCTION _ListText()
	_reset()
	$text[1]  = "                   GEMS DEMO - List Box"
	$text[2]  = ""
	$text[3]  = "The list box was intended to replace SCREEN PROMPT, allowing"
	$text[4]  = "options with spaces in them, but can be used for any sort of"
	$text[5]  = "selection. Multi-selection, columns & sorting are options."
	$text[6]  = ""
	$text[7]  = "A string of items, with the separating character used, are"
	$text[8]  = "passed in. A space separated string of the selected options,"
	$text[9]  = "by number, for use with the GROUP function is returned. A"
	$text[10] = "variable is also populated with the selected options text."
	$text[11] = ""
	$text[12] = ""
	$text[13] = "  Example 1: Single selection, single column."
	$text[14] = ""
	$text[15] = "     Esc for the Menu - Any other key for the list box"
	#col[1,1] = 10
	#col[13,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _CheckList()
 LOCAL $options $temp
	IF _CheckText() = {esc}
		RETURN {esc}
	END IF
	$options = "First One"|CHR(47)|"Spaces in No.2"|CHR(47)|"Another one"|CHR(47)|"Four"|CHR(47)|"Final choice"
	$temp = _GEMS_CheckList("Check list example","Select the required item(s)",$options,0,47)
	IF #GEMS_Cancel
		$text[12] = "          You cancelled:" & $temp & "(empty string returned)"
	ELSE
		$text[12] = "    You selected option(s) number:" & $temp & "- (text below)"
		$text[13] = REPEAT(" ",INT((60-LEN($GEMS_SelectedOptions))/2))|$GEMS_SelectedOptions
		#col[13,1] = 10
	END IF
	$text[15] = "       Esc for the Menu - Any other key to continue"
	RETURN _display(1)
END FUNCTION

FUNCTION _CheckText()
	_reset()
	$text[1]  = "                   GEMS DEMO - Check List"
	$text[2]  = ""
	$text[3]  = "An alternative to a list box, the check list is for multiple"
	$text[4]  = "item selection by checking the boxes of the required ones."
	$text[5]  = "Sorting and multiple columns are options."
	$text[6]  = ""
	$text[7]  = "A string of items, with the separating character used, are"
	$text[8]  = "passed in. A space separated string of the selected options,"
	$text[9]  = "by number, for use with the GROUP function is returned. A"
	$text[10] = "variable is also populated with the selected options text."
	$text[11] = ""
	$text[12] = "  Press any key for the example."
	$text[13] = "         N.B. See the list box for similar examples."
	$text[14] = ""
	$text[15] = "    Esc for the Menu - Any other key for the check list"
	#col[1,1] = 10
	#col[12,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _Datepicker()
'Note that the first call to GEMS_Date has numeric dates, the second has text ones.
 LOCAL $temp
	IF _DateText() = {esc}
		RETURN {esc}
	END IF
	$temp = _GEMS_Date("This is a date picker","Select the required date",0,0,TODAY,0)
	IF #GEMS_Cancel
		$text[8] = "      You cancelled:" & $temp & "(initial value)"
	ELSE
		$text[8] = "      You selected:" & $temp
	END IF
	$text[9] = "Another key press starts a date picker for 2002, the today"
	$text[10] = "indicator & week numbers are on, Wednesday is week day 1."
	#col[9,1] = 10
	#col[10,1] = 10
	IF _display(1) = {esc}
		RETURN {esc}
	END IF
'Use ADDDAYS function on the max date to avoid date format issues dd/mm/yyyy or mm/dd/yyyy
	$temp = _GEMS_Date("","Select the required date","1/1/2002",ADDDAYS("1/1/2003",-1),"",27)
	IF #GEMS_Cancel
		$text[11] = "      You cancelled:" & $temp & "(no initial value)"
	ELSE
		$text[11] = "      You selected:" & $temp
	END IF
	$text[15] = "     Esc for the Menu - Any other key to continue"
	RETURN _display(1)
END FUNCTION

FUNCTION _DateText()
	_reset()
	$text[1]  = "                  GEMS DEMO - Date Picker"
	$text[2]  = ""
	$text[3]  = "This function gives a calendar interface for date entry. You"
	$text[4]  = "can specify min, max and the initial date. The date range"
	$text[5]  = "available is 1 January 1753 to 31 December 9999."
	$text[6]  = ""
	$text[7]  = "  Your next key press will bring up the date picker"
	$text[8]  = ""
	$text[9]  = ""
	$text[10] = ""
	$text[11] = ""
	$text[12] = ""
	$text[13] = "N.B. Left click on the month or year for quicker changes."
	$text[14] = ""
	$text[15] = "   Esc for the Menu - Any other key for the date picker"
	#col[1,1] = 10
	#col[7,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _TimePicker()
'Note that the first call to GEMS_Time has numeric times, the second has text ones.
 LOCAL $temp
	IF _TimeText() = {esc}
		RETURN {esc}
	END IF
	$temp = _GEMS_Time("This is a time picker","Select the required time","","",0.5,1)
	IF #GEMS_Cancel
		$text[7] = "     You cancelled:" & $temp & "(initial value)"
	ELSE
		$text[7] = "     You selected:" & $temp
	END IF
	$text[9] = "  Another key press starts a second time picker with AM/PM"
	$text[10] = "  HH:MM display. Min and max times set to 9:00 to 5:30PM"
	#col[9,1] = 10
	#col[10,1] = 10
	IF _display(1) = {esc}
		RETURN {esc}
	END IF
	$temp = _GEMS_Time("","Select the required time","09:00","05:30PM","09:00",4)
	IF #GEMS_Cancel
		$text[11] = "     You cancelled:" & $temp & "(initial value)"
	ELSE
		$text[11] = "     You selected:" & $temp
	END IF
	$text[13]  = "N.B. Max can be set less than min to select overnight time"
	$text[15] = "     Esc for the Menu - Any other key to continue"
	RETURN _display(1)
END FUNCTION

FUNCTION _TimeText()
	_reset()
	$text[1]  = "                  GEMS DEMO - Time Picker"
	$text[2]  = ""
	$text[3]  = "This function lets you enter times. You can put a min and max"
	$text[4]  = "time as well as the start time."
	$text[5]  = ""
	$text[6]  = "  Your next key press starts the time picker (24hr)"
	$text[7]  = ""
	$text[8]  = ""
	$text[9]  = ""
	$text[10] = ""
	$text[11] = ""
	$text[12] = ""
	$text[13] = ""
	$text[14] = ""
	$text[15] = "   Esc for the Menu - Any other key for the time picker"
	#col[1,1] = 10
	#col[6,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _ScrollBar()
 LOCAL #temp
	IF _ScrollText() = {esc}
		RETURN {esc}
	END IF
	#temp = _GEMS_ScrollBar("This is a scroll bar","Select the value you want",0,10,5)
	IF #GEMS_Cancel
		$text[8] = "      You cancelled:" & STR(#temp) & "(initial value)"
	ELSE
		$text[8] = "      You selected:" & STR(#temp)
	END IF
	$text[9] = "  Next example has no title bar and moves in steps of 15"
	#col[9,1] = 10
	IF _display(1) = {esc}
		RETURN {esc}
	END IF
	#temp = _GEMS_ScrollBarEx("","Select the value you want",0,180,30,15,15)
	IF #GEMS_Cancel
		$text[10] = "      You cancelled:" & STR(#temp) & "(initial value)"
	ELSE
		$text[10] = "      You selected:" & STR(#temp)
	END IF
	$text[15] = "     Esc for the Menu - Any other key to continue"
	RETURN _display(1)
END FUNCTION

FUNCTION _ScrollText()
	_reset()
	$text[1]  = "                GEMS DEMO - Scroll Bar"
	$text[2]  = ""
	$text[3]  = "Here is a Windows standard way to select a numeric value."
	$text[4]  = "You specify the min, max and starting values - the function"
	$text[5]  = "returns the users selection."
	$text[6]  = ""
	$text[7]  = "  Your next key press will bring up the scroll bar"
	$text[8]  = ""
	$text[9]  = ""
	$text[10] = ""
	$text[11] = ""
	$text[12] = "Note SmartWare operation is stopped until you OK or Cancel"
	$text[13] = "the scroll bar. See the track bar for similar examples."
	$text[14] = ""
	$text[15] = "   Esc for the Menu - Any other key for the scroll bar"
	#col[1,1] = 10
	#col[7,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _DisplayMessage()
	IF _DMText() = {esc}
		RETURN {esc}
	END IF
	_GEMS_Display_Message("A sinlgle message line in this example","",4)
	$GEMS_RADFuncTitle = "Optional title"
	_GEMS_Display_Message("Two message lines this time","The RAD function this replaces cannot have a title",4)
	#GEMS_bg = 11
	#GEMS_fg = 2
	$GEMS_fposition = "MT"
	#GEMS_fpercentage = 75
	#GEMS_fontsize = 40
	_GEMS_Display_Message("Colour, position and fontsize options shown now","",4)
	_GEMS_ResetStdParam()
	$GEMS_RADFuncTitle = " "
END FUNCTION

FUNCTION _DMText()
	_reset()
	$text[1]  = "              GEMS DEMO - Display Message"
	$text[2]  = ""
	$text[3]  = "This is a Windows replacement for the RAD display_message"
	$text[4]  = "function used to display a two line message and OK button."
	$text[5]  = ""
	$text[6]  = " Keep pressing return or clicking OK to see the 3 examples"
	$text[7]  = " The first example is a straight forward replacement"
	$text[8]  = " The second has an optional title (not available in RAD)"
	$text[9]  = " The third shows font, colour and positioning options"
	$text[10] = ""
	$text[11] = "Parameters have been kept the same as the RAD function,"
	$text[12] = "including the unused third one, so it can be easily"
	$text[13] = "implemented by a replace on the function name."
	$text[14] = ""
	$text[15] = "  Esc for the Menu - Any other key for the first example"
	#col[1,1] = 10
	#col[6,1] = 10
	#col[7,1] = 10
	#col[8,1] = 10
	#col[9,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _GetChoice()
	IF _GCText() = {esc}
		RETURN {esc}
	END IF
	_GEMS_Get_Choice("Only one of the four text lines used","","","","One Two Three",4)
	$GEMS_RADFuncTitle = "Optional title"
	#GEMS_GCSepChar = ASC(";")
	_GEMS_Get_Choice("The optional title is not available in the RAD function this replaces","","","You can also now have spaces in the button text","First Choice;Second Choice",4)
	#GEMS_GCSepChar = ASC(" ")
	#GEMS_bg = 12
	#GEMS_fg = 15
	$GEMS_fposition = "RB"
	#GEMS_fwidth = 400
	#GEMS_fontsize = 20
	_GEMS_Get_Choice("All the colour, position and fontsize options","of GEMS are available","","","OK Cancel",4)
	_GEMS_ResetStdParam()
	$GEMS_RADFuncTitle = " "
END FUNCTION

FUNCTION _GCText()
	_reset()
	$text[1]  = "                GEMS DEMO - Get Choice"
	$text[2]  = ""
	$text[3]  = "A Windows replacement for the RAD get_choice function"
	$text[4]  = "used to display up to 4 linse with options for selection."
	$text[5]  = ""
	$text[6]  = " Keep pressing return or clicking OK to see the 3 examples"
	$text[7]  = " The first example is a straight forward replacement"
	$text[8]  = " The second shows extensions to the RAD version"
	$text[9]  = " The third shows font, colour and positioning options"
	$text[10] = ""
	$text[11] = "Parameters have been kept the same as the RAD function,"
	$text[12] = "including the unused sixth one. The function returns the"
	$text[13] = "number of the option selected. as the RAD version does."
	$text[14] = ""
	$text[15] = "  Esc for the Menu - Any other key for the first example"
	#col[1,1] = 10
	#col[6,1] = 10
	#col[7,1] = 10
	#col[8,1] = 10
	#col[9,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _params1()
	_reset()
	$text[1]  = "      Options, Parameters & Windows API Functions"
	$text[2]  = ""
	$text[3]  = "We have tried to make GEMS both easy to use & flexible. All"
	$text[4]  = "the functions have their own parameters, specified in the"
	$text[5]  = "call, explained in sections 1 and 2 of this demo."
	$text[6]  = ""
	$text[7]  = "There are also 8 standard parameters & 3 control parameters"
	$text[8]  = "you can set via variables to control font size, colour,"
	$text[9]  = "position etc."
	$text[10] = ""
	$text[11] = "Other variables control the DLL location & whether SmartWare"
	$text[12] = "errors are raised by GEMS. The returns from some functions"
	$text[13] = "are available in multiple ways and formats. Windows API"
	$text[14] = "functions has also been included, some are shown later."
	$text[15] = "    Esc for the Main Menu - Any other key to continue"
	#col[1,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _params2()
	_reset()
	$text[1]  = "What are the 8 standard parameters ?"
	$text[2]  = ""
	$text[3]  = "Position - controls where the function appears, left/middle"
	$text[4]  = "  right and top/middle/bottom - default is middle middle."
	$text[5]  = "FG & BG - control the foreground and background colours. The"
	$text[6]  = "  SmartWare colour numbers are used."
	$text[7]  = "Bounds - controls what the position and sizing options for"
	$text[8]  = "  the function relate to. This can be the desktop, the full"
	$text[9]  = "  SmartWare window or parts of it. Options include the area"
	$text[10] = "  of a SmartWare window inside the scroll bars. (N.B. the"
	$text[11] = "  Windows exe demo cannot use the SmartWare partial options)"
	$text[12] = "FontSize - does what it says, valid options are 8-40. The"
	$text[13] = "  actual size used is varied to fit a specified size or"
	$text[14] = "  bounding window."
	$text[15] = "    Esc for the Main Menu - Any other key to continue"
	#col[1,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _params3()
	_reset()
	$text[1]  = "....8 standard parameters continued"
	$text[2]  = ""
	$text[3]  = "Width & height - the size of the function window can be set"
	$text[4]  = "  in pixels. It is subject to minimums and the bounding"
	$text[5]  = "  window size. Height is ignored in some cases - e.g. date"
	$text[6]  = "  picker. Percentage takes priority over width and height."
	$text[7]  = "Percentage - specifies the size to make the window relative"
	$text[8]  = "  to the bounding window. In some cases only width is set."
	$text[9]  = ""
	$text[10] = "What about the 3 control parameters ?"
	$text[11] = ""
	$text[12] = "They set the colours and font size for the entry part of the"
	$text[13] = "input box, time picker, list box and check list."
	$text[14] = ""
	$text[15] = "    Esc for the Main Menu - Any other key to continue"
	#col[1,1] = 10
	#col[10,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _params4()
 LOCAL $temp
	IF _params4Text() = {esc}
		RETURN {esc}
	END IF
	$temp = _GEMS_WinDialog("No icon and just the one button","I O Systech Windows Dialog Example 1",0)
	#col[12,1] = #fg
	#col[13,1] = 10
	$text[11] = "                In example 1 you pressed:" & $temp
	$text[12] = ""
	$text[13] = "      Example 2: add an icon and multiple buttons"
	IF _display(1) = {esc}
		RETURN {esc}
	END IF
	$temp = _GEMS_WinDialog("Icon and multiple buttons"|CHR(10)|"Text can be on multiple lines too.","I O Systech Windows Dialog Example 2",65)
	$text[11] = "                In example 2 you pressed:" & $temp
	$text[13] = "      Example 3: different icon and multiple buttons"
	IF _display(1) = {esc}
		RETURN {esc}
	END IF
	$temp = _GEMS_WinDialog("Different icon and buttons for a question","I O Systech Windows Dialog Example 3",35)
	$text[11] = ""
	$text[12] = "                In example 3 you pressed:" & $temp
	$text[13] = ""
	$text[15] = "    Esc for the Main Menu - Any other key to continue"
	RETURN _display(1)
END FUNCTION

FUNCTION _params4Text()
	_reset()
	$text[1]  = "What about the Windows API functions ? (dialog first)"
	$text[2]  = ""
	$text[3]  = "The Windows dialog function is not counted amongst the 14"
	$text[4]  = "GEMS elements because it is produced from API calls, and not"
	$text[5]  = "calls to the GEMS DLL. It has also been available from our"
	$text[6]  = "website and is included in our SWiP product."
	$text[7]  = ""
	$text[8]  = "A function call with three parameters gives you a dialog box"
	$text[9]  = "with optional text and your selection of buttons & icon."
	$text[10] = ""
	$text[11] = ""
	$text[12] = "      Example 1: no icon and single button"
	$text[13] = ""
	$text[14] = ""
	$text[15] = "    Esc for the Main Menu - Any other key for the dialog"
	#col[1,1] = 10
	#col[12,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _params5()
	_reset()
	$text[1]  = "What other Windows API based functions are there?"
	$text[2]  = ""
	$text[3]  = "The SetSWTitle function has been called to change the title"
	$text[4]  = "in the caption bar. GEMS also has a function, SetSWIcon to"
	$text[5]  = "change the icon."
	_GEMS_SetSWTitle("Title set by the GEMS demo at:" & TIME24)
	$text[6]  = ""
	$text[7]  = "Other GEMS functions can be used to return paths to system"
	$text[8]  = "folders or the command line (N.B. values may be truncated)."
	$text[9]  = LEFT("  Windows folder:"&_GEMS_GetDir(2),60)
	$text[10] = LEFT("  Command Line  :"&_GEMS_SWCmndLine(),60)
	$text[11] = ""
	$text[12] = "Additional functions will open web sites, generate emails"
	$text[13] = "produce an about box, open folders, print & run programs."
	$text[14] = ""
	$text[15] = "                  Press any key to continue"
	#col[1,1] = 10
	#col[9,1] = 10
	#col[10,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _SWiP1()
	_reset()
	$text[1]  = "What other SmartWare products do I O Systech have ?"
	$text[2]  = ""
	$text[3]  = "We have many years experience producing applications, RAD"
	$text[4]  = "& non-RAD, in the UK. These bespoke applications are not"
	$text[5]  = "available as products however we do produce SWiP (Smartware"
	$text[6]  = "Windows Printing)."
	$text[7]  = ""
	$text[8]  = "Tell me more about SWiP"
	$text[9]  = ""
	$text[10] = "SWiP enables SmartWare to integrate printing through Crystal"
	$text[11] = "Reports (v7, 8 & 8.5) & Microsoft Word (97, 2000 & 2002/XP)."
	$text[12] = "It incorporates an optional facility for automatic printer"
	$text[13] = "selection, including specific trays, for each printout."
	$text[14] = ""
	$text[15] = "    Esc for the Main Menu - Any other key to continue"
	#col[1,1] = 10
	#col[8,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _SWiP2()
	_reset()
	$text[1]  = "The printer selection is user configurable via a Windows"
	$text[2]  = "executable which may be run via process_create from your"
	$text[3]  = "project. It includes modes to check the validity of the"
	$text[4]  = "printer configuration at application startup."
	$text[5]  = ""
	$text[6]  = "Both Crystal and Word printouts can print the first page"
	$text[7]  = "from a different tray. Multiple copies can be printed and up"
	$text[8]  = "to 99 printers can be configured (a printer to SWiP can be"
	$text[9]  = "a physical printer or specific trays on a printer)."
	$text[10] = ""
	$text[11] = "Is it only for RAD applications ?"
	$text[12] = ""
	$text[13] = "No, it was developed for RAD but v3.x can be used from any"
	$text[14] = "project."
	$text[15] = "    Esc for the Main Menu - Any other key to continue"
	#col[11,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _SWiP3()
	_reset()
	$text[1]  = "How can I use Crystal reports ?"
	$text[2]  = ""
	$text[3]  = "Crystal printouts can be directed to a printer, previewed"
	$text[4]  = "on screen or exported to PDF. We support v7, 8 & 8.5, you"
 	$text[5]  = "only need 1 copy of Crystal to develop the reports as user"
 	$text[6]  = "support can be distributed royalty free. Collation, duplex,"
	$text[7]  = "landscape, multiple copies, first page from a different"
	$text[8]  = "tray and progress dialog suppression are all available."
	$text[9]  = "Advanced custom API calls are used to offer extended"
	$text[10] = "functionality and even fix some Crystal limitations."
	$text[11] = ""
	$text[12] = "In the preview window you control if the print, print setup"
	$text[13] = "& export buttons are shown. It can also be maximised & wait"
	$text[14] = "optionally in SmartWare for it to be closed."
	$text[15] = "    Esc for the Main Menu - Any other key to continue"
	#col[1,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _SWiP4()
	_reset()
	$text[1]  = "What are the 6 modes SWiP can print via Word ?"
	$text[2]  = ""
	$text[3]  = " - Automatic printing"
	$text[4]  = " - Forced save (you specify default directory/folder)"
 	$text[5]  = " - Printer selection with automatic printing"
 	$text[6]  = " - Full user control of the merged document"
	$text[7]  = " - Automatic save & edit"
	$text[8]  = " - Template editing"
	$text[9]  = ""
	$text[10] = "Is there anything else I need to know about SWiP & Word ?"
	$text[11] = ""
	$text[12] = "Word 97, 2000 & 2002/XP are supported - you need a licence"
	$text[13] = "for each user. You control, via variables, whether SWiP"
	$text[14] = "waits for Word to close, checks before the next call, etc."
	$text[15] = "    Esc for the Main Menu - Any other key to continue"
	#col[1,1] = 10
	#col[10,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _SWiP5()
	_reset()
	$text[1]  = "Is SWiP easy to use ?"
	$text[2]  = ""
	$text[3]  = "Yes - ease of use without sacrificing functionality is one"
	$text[4]  = "of our aims with SWiP and GEMS."
	$text[5]  = ""
	$text[6]  = "How much does SWiP cost?"
	$text[7]  = ""
	$text[8]  = "UK price is 185 pounds (Pro version, with source code, 475)."
	$text[9]  = "US dollar price is 295 (Pro 735). Distribution to clients"
	$text[10] = "requires a site licence, like GEMS. Charged at 30 pounds for"
	$text[11] = "the first user + 6 pounds per additional user at each site"
	$text[12] = "to a maximum of 130 pounds/site . In US dollars - 50, 10 &"
	$text[13] = "max. 210. Website has full details - inc. developer bundles."
	$text[14]  = ""
	$text[15] = "                  Press any key to continue"
	#col[1,1] = 10
	#col[6,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _general1()
	_reset()
	$text[1]  = "Who are I O Systech ?"
	$text[2]  = ""
	$text[3]  = "I O Systech are a UK based IT consultancy specialising in"
	$text[4]  = "application development for the medium and small enterprise."
	$text[5]  = ""
	$text[6]  = "Primarily using Borland Delphi and SmartWare, our team has"
	$text[7]  = "expertise in the following industry sectors;"
	$text[8]  = "   water"
	$text[9]  = "   leisure"
	$text[10] = "   retail"
	$text[11] = "   insurance and personal injury"
	$text[12] = "   business services"
	$text[13] = "   engineering"
	$text[14] = ""
	$text[15] = "    Esc for the Main Menu - Any other key to continue"
	#col[1,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _general2()
	_reset()

	$text[1]  = "What else do I O Systech do ?"
	$text[2]  = ""
	$text[3]  = "Our core business is bespoke applications for our clients."
	$text[4]  = "However we also provide IT consultancy and training along"
	$text[5]  = "with a range of products."
	$text[6]  = ""
	$text[7]  = "If you have been through all this demo program you will be"
	$text[8]  = "familiar with our two SmartWare products - GEMS and SWiP."
	$text[9]  = "(in case not - SWiP is a Crystal & Word printing toolkit)."
	$text[10] = ""
	$text[11] = "Other products released or being developed include a water"
	$text[12] = "usage calculator, bulletin  board (shares data around a"
	$text[13] = "company and our F1 quiz. Email (enquiries@iosystech.co.uk"
	$text[14] = "for details."
	$text[15] = "                  Press any key to continue"
	#col[1,1] = 10
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _exit()
	_reset()
	$text[1]  = "Thank you for trying the GEMS demonstration."
	$text[2]  = ""
	$text[3]  = "We are always interested in your feedback on our products or"
	$text[4]  = "demonstrations - good or bad. Our contact details are below"
	$text[5]  = "for feedback, additional information or ordering."
	$text[6]  = ""
	$text[7]  = "                     I O Systech Ltd"
	$text[8]  = "8 Willow Walk, Englefield Green, Egham, Surrey, TW20 0DQ, UK"
	$text[9]  = "             Website:  www.iosystech.co.uk"
	$text[10] = "             Email:    enquiries@iosystech.co.uk"
	$text[11] = "    Phone: +44 (0)1784 432058     Fax: +44 (0)8707 064666"
	$text[12] = ""
	$text[13] = "      ORDER GEMS AND SWiP NOW - SEE WEBSITE FOR DETAILS"
	$text[14] = ""
	$text[15] = "                   Press any key to exit"
	#col[3,1] = 10
	#col[4,1] = 10
	#col[5,1] = 10
	#col[13,1] = 15
	#col[15,1] = 14
	RETURN _display(1)
END FUNCTION

FUNCTION _IncharClear()
' GEMS encourages mouse usage but the SmartWare mouse handling is not perfect.
' This routine discards mouse up events if the user responds with the mouse
' instead of the keyboard - otherwise mouse up is treated as another key press.
' Similar techniques should be used with the MESSAGE and WAIT commands.
 LOCAL $tempkey
	$tempkey = INCHAR
	WHILE MOUSEINFO(m_buttons) <> 42
		MILLI-WAIT 5
	END WHILE
	WHILE NEXTKEY
		INEVENT
	END WHILE
	RETURN $tempkey
END FUNCTION

