Demo 5

Demo 5 shows how to use Java Script to bring up a popup window. This allows you to bring up a non-modal window. You can get runtime data onto the popup, however it has no connection SM32 once it is running so no data can be returned. This is the way the utilities do the
[Info on this Utility] link.
Take a look at D_D5POPUP. A lot of the $__EMPTY code has been deleted. Only the code to get the html code into the file has been kept. Also note P![all] has been removed from the ENTER and the html is placed into "TEMPHELP.HTML" instead of "TEMP.HTML".

Demo 6

Since SM32 Dialog boxes (created by $__DIALOG) are not resizable and have no scroll bars you may on occasion want to put an <IFRAME>(Floating Frame) with scroll bars inside a dialog box. The supplied routine $__IFRAME_DIALOG does this. For this demo $__IFRAME_DIALOG was saved as D6IFRAME and a couple of modifications were made. The name of the frame was changed from IF to D6IFRAME and a header was added on top of the IFRAME. If you run the Compare Source utility for the 2 programs $__IFRAME_DIALOG and D6IFRAME you will see these changes. Also note that the Compare Utility itself uses $__IFRAME_DIALOG unmodified for its comparison display. And note in DEMO6 that the FRAME is selected by setting:
P!["FRAME"]="D6IFRAME"

Demo 7

When using the Web View you can capture the user resizing the window. The following code turns this on:
100 dim k!
110 k!["type"]="SendSizeChange"
120 k!["State"]="On"
130 WRITE GUI K![all]
With SendSizeChange turned on a program based on $__EMPTY will return P!["url"]="SizeChange" when the user resizes the window. The following turns off receiving SizeChange.
100 dim k!
110 k!["type"]="SendSizeChange"
120 k!["State"]="Off"
130 WRITE GUI K![all]
Demo 7 sets 2 font sizes based on the width of the window.

Demo 8

Demo 8 shows how to handle input from Menu Builder and Toolbar Builder generated programs.

Menu Builder creates the program D8MENU. D8Menu also contains the data required to edit the menu with the the Menu Builder. (at Line 4000->4xxx). To edit the menu:
1. Bring up Menu Builder under utilities.
2. Browse for program D8MENU
3. Select the name D8MENU for the menu name.

Note the Display ID#'s. This will bring up a popup that will display all the ID#'s you assigned while building your menu. You can then either leave the popup on screen or right click and print it. This gives you an easy way to see ID#'s you are going to use on your toolbar as well as all the ID#'s your program will have to handle.

Toolbar Builder creates DEMO8TB.html D_DEMO8TB and DEMO8TB_LOAD_IMAGES. The Toolbar Project information is contained in DEMO8_TBPROJ. Toolbar Builder expects you to create a number of 20 pixel x 20 pixel images in a directory. Then create a project in that directory. The process for demo 8 was a follows:
1. Directory DEMO8TB was created.
2. The 3 images MB_NEW.JPG MB_OPEN.JPG and MB_PRINT.JPG were placed in DEMO8TB.
3. Tollbar Builder was then started. The DEMO8TB directory was selected and the File Name for the project was set to DEMO8TB.
4. The message "Create new project: DEMO8TB in C:\.....\test\DEMO8TB\" appearred and OK was selected.
5. Append was selected and MB_NEW.JPG selected:
    User Prompt:  
    ID Number:    
   Append was selected and MB_OPEN.JPG selected:
    User Prompt:  
    ID Number:    
   Append was selected and MB_PRING.JPG selected:
    User Prompt:  
    ID Number:    
6. Finished was Selected.

The DEMO8 Program:
Display's the Menu created by Menu Builder
40 RCALL "D8MENU",""
Display's the Toolbar created by Toolbar Builder
50 RCALL "D_DEMO8TB",""
The Toolbar is a Frame, so the main window becomes frame "MAIN". This must be set before calling LOAD HTML created programs like D_DEMO8.
80 LET P!["FRAME"]="MAIN"
90 RCALL "D_DEMO8",P![ALL],M$
LOAD HTML created programs make Toolbar buttons look like Menu Items so all that DEMO8 handles is a url of "Menu Selected"
100 IF P!["url"]<>"Menu Selected" THEN ESCAPE 
110 IF P!["Menu Item"]="30100" THEN LET M$="You are creating a NEW Something";GOTO 0080
120 IF P!["Menu Item"]="30101" THEN LET M$="You are OPENing Something";GOTO 0080
130 IF P!["Menu Item"]="30102" THEN LET M$="You want to PRINT Something";GOTO 0080
The default config defines close (x in upper right) to look like Menu Item # 39999. So File->Exit is equivalent to close.
140 IF P!["Menu Item"]<>"39999" THEN ESCAPE 
150 INPUT 'ee','messagebox'("Demo 8","This will end Demo 8",""),R,'be',
Delete the menu.
160 PRINT 'menu'("DELETE","WEB","D8MENU"),
The D_DEMO8TB was based on $__EMPTY_TB_TOP not $__EMPTY. However you can still modify DEMO8TB.HTML and update D_DEMO8TB with the Load Html utility. (See Demo 8X)
The D_DEMO8TB program Load the images. If you look in the HTML\IMAGES directory you will see the images have had the Toolbar project name prefixed to the (eg, DEMO8TB_MB_NEW.JPG)
110 CALL "DEMO8TB_LOAD_IMAGES",""
D_DEMO8TB has 2 peices of HTML. The HTML that defines the frames. "TB" is the Toolbar; "MAIN" is the rest of the window. The code at 80000 is the regular LOAD HTML code, it comes from DEMO8TB.HTML and is the HTML generated by the Toolbar Builder.
115 CALL GET_FRAME,A$

70000 REM 70000,5                              
70005 GET_FRAME: 
70010 ENTER A$
70015 LET A$=""
70020 LET A$="<HTML><HEAD><TITLE></TITLE></HEAD>"+$0A$
70025 LET A$=A$+"<FRAMESET border=0 rows=35,*>"+$0A$
70030 LET A$=A$+"<FRAME BORDER=0 SCROLLING="+$22$+"NO"+$22$
70030:+" MARGINWIDTH="+$22$+"2"+$22$+" NAME="+$22$+"TB"+$22$+">"+$0A$
70035 LET A$=A$+"<FRAME border=0 NAME="+$22$+"MAIN"+$22$+">"+$0A$
70040 LET A$=A$+"</FRAMESET>"+$0A$
70045 LET A$=A$+"</HTML>"+$0A$
70050 EXIT 
Note the HTML from 80000 is sent to the frame named "TB".
255 CALL GET_HTML,A$
260 LET A$=DCMP(A$)
...
...
355 LET K!["frame name"]="TB"
Also Note D_DEMO8TB does not PEND waiting for input but returns to DEMO8. DEMO8 then calls D_DEMO8 which was based on $__EMPTY so it does pend waiting for input.
D_DEMO8 gets menu input:
540 READ 'ee',A,'be',
545 LET P!["url"]="Menu Selected"
550 LET P!["Menu Item"]=STR(A)
555 EXIT
and makes Toolbar Input look like menu input:
625 IF U$<>"http://t/" THEN GOTO 0640;REM "not a toolbar click"
630 LET U$="Menu Selected";REM "Make like a Menu Item was Selected"
635 LET P!["Menu Item"]=P!["MENUITEM"]
640 LET P!["url"]=U$

Demo 8X

DEMO8X takes DEMO8 and manually adds a Select and a Text Input to the Toolbar. To Start the following were copied:

DEMO8TB.HTML -> DEMO8XTB.HTML
D_DEMO8TB -> D_DEMO8XTB
DEMO8 -> DEMO8X
The following was added to DEMO8XTB.HTML:
&nbsp;&nbsp;
<select name=sinfo onchange="bclick(0)" SIZE=1 STYLE="font: 13pt">
<option SELECTED VALUE="none">--- select something ---</option>
<option value="opt1">Option 1</option>
<option value="opt2">Option 2</option>
<option value="opt3">Option 3</option>
</select>
&nbsp;&nbsp;
<B STYLE="font: 14pt">Enter Something:</b>
<input onkeyup="bclick(0)" TYPE="Text" NAME=info VALUE="" SIZE=20>
D_DEMO8XTB was updated by running the Load Html untility.

DEMO8X added the the following code to keep the variables SINFO$ and INFO$ tracking the on screen value of the Select named "sinfo" and the Text Box named "info".
120 IF P!["Menu Item"]<>"0" THEN GOTO 0170
130 LET P!["FLAG"]="NoDisplay"
140 LET SINFO$=P!["sinfo"]
150 LET INFO$=P!["info"]
160 GOTO 0090
This method was used so that the "sinfo" and "info" data was available even when a real Menu Item is selected not just a Toolbar button. That is there is no posted data when a Menu Item is selected.

Demo 9

Demo 9 is Demo 1 with a menu added.
It demonstrates how to build a menu without using the menu builder - see DEMOMENU
It also demonstrates how to ask Internet Explorer to do the following on the currently loaded web view:
PageSetup, FilePrint, PrintPreview, Cut, Copy, Paste, and SelectAll

Demo 10

Demo 10 shows how to do a HTML Print with no user intervention. It does this by:
- sets the header,footer and orientation ($__PAGE_SETUP)
- bring up a Dialog Box ($__DIALOG)
- loads the HTML (D_DEMO10 with JustDisplay flag)
- does a FilePrint with DONTPROMPTUSER option
- ends the Dialog Box($__ENDDIALOG)
- restores the header,footer and orientation ($__PAGE_SETUP)

Create Distribution Tutorial

Do the following:
1. LOAD DEMO1 and add a line
200 Q$=Q$(9)
run DEMO1 to verify it ends in an error 47 at line 200


2. Under utilities run Create Distribution. Leave all the defaults except make the start program DEMO1 instead of START


3. Do a
SETDISK 5,"..\RELEASE\SMPGMLIB"
LOAD "DEMO1"
LIST
you will se the following:

010 NS
100 NS
105 NS
110 NS
115 NS
120 NS
125 NS
130 NS
135 NS
140 NS
145 NS
150 NS
155 NS
160 NS
165 NS
200 NS
This demonstrates a couple of things. First SM32 always loads programs from the program libraries first. Secondly the Create Distribution actually changes all the source to NS rather than removing it.
do a
SETDISK 5,""
LOAD "DEMO1"
you should get the test version back

4. With Windows Explorer goto to the Release directory and double click SM32. DEMO1 should start running. Click Do It. A message box titled "Fatal Error Condition" will appear stating A Fatal Error Log has been created and asking Do you want to restart this application.

This message is being displayed by the program $__FATAL. If you answer yes it will simply RUN "DEMO1". Answer NO and check out the log file. It will be called "$__FATAL_LOG"+DAS+".LOG". Edit it with WORDPAD. You should see error 47 at line 200 followed by a DUMP.

5. From "$__FATAL" examine the following code:

1035 LET A$="A Fatal Error Log has been created"
1040 GOTO 2100
2000 REM 2000 An executing program executed an end or stop statement
2010 REM Or anything that would print >READY                              
2020 LET A$="Program: "+NAM$+" has STOPPED executing"
2100 REM 2100,5                              
2105 LET A$=A$+$0A$+"Do you want to restart this aplication ?"
2110 INPUT 'ee','messagebox'("Fatal Error Condition",A$,"420"),A$,'be',
2115 IF A$<>"6" THEN BYE 
2120 LET A![ALL]=CONFIG
2125 LET A$=A!["system  initial_statement"]
2130 LET P=POS("run"=CVS(A$,#cvs_to_lower))
2135 IF P=0 THEN BYE 
2140 LET A$=A$(P)
2145 GOTO 4000
There are 2 messages that can occur:
Line 2020 sets the message if a STOP or END statement is executed
Line 1035 sets the message if an ERROR occurred like the error 47
Before coming to Line 1035 $__FATAL has preformed the following: Created the log file, opened it on channel U and written the error information into it. It then simulated the following console mode commands:
DUMP(U)
NEW
This is being shown here with the idea that you may want to modify 2110 to ask your users to e-mail the FATAL log to yourself. Lines 2120->2140 pull the startup RUN statement from the configuration.