PROGRAM ENABLE_DEMO_FORM !+ ! ! Purpose of FORMS$DEMO_ENABLE ! ---------------------------- ! ! This program ENABLEs demonstration forms, optionally passing control text. ! It makes several assumptions about the forms it enables: ! ! 1) It assumes the name of the Form is the same as the name of the file. ! (except for Digital supplied demonstrations, where "FORMS$" is ! stripped from the filename). ! ! 2) It assumes the Form will take over control during the ENABLE, ! and will keep control until demo is complete. ! This means you need to create an ENABLE RESPONSE in the form, ! which Activates/Positions/Lets as appropriate to demo the form. ! You can also pass control text to the form to use additional ! responses. ! ! ! Using FORMS$DEMO_ENABLE ! ----------------------- ! ! To use this program, follow these steps: ! ! 1) Define this symbol (assuming this program is in forms$examples:): ! ! $ enable := $forms$examples:forms$demo_enable ! ! 2) Run your demo form like this: ! ! $ enable ! ! The form can be a .FORM file, or a .EXE file (shareable image) ! Shareable images startup much faster then .FORM files. ! ! The form name may be passed on the input line (as shown above) ! or defined as the logical FORMS$DEMO_FORM. ! ! ! Follow these steps to create your own demo forms ! ------------------------------------------------ ! ! 1) Make the internal form name be the same as the file name. ! ! For example, the file: DEMO_MYFORM_FORM.IFDL ! would contain: Form DEMO_MYFORM_FORM ! . . . ! End Form ! ! 2) Translate the Form ! ! $ FORMS TRANSLATE /NOCOMMENTS ! ! 3) Link the Form into a shareable image ! ! $ FORMS EXTRACT OBJECT ! $ LINK /SHAREABLE ! ! NOTE: The FORMS$DEMO.COM procedure (in FORMS$EXAMPLES:) uses a naming ! convention for files that requires user-supplied demo files ! be called: DEMO_xxx_FORM.EXE. ! ! For example: If your form name was DEMO_MYFORM_FORM, ! the commands to build the image would be: ! ! $ FORMS TRANSLATE DEMO_MYFORM_FORM /NOCOMMENTS ! $ FORMS EXTRACT OBJECT DEMO_MYFORM_FORM ! $ LINK DEMO_MYFORM_FORM /SHAREABLE ! !- OPTION TYPE = EXPLICIT %PAGE %SBTTL "Declarations" %INCLUDE "sys$library:FORMS$BAS_DEFINITIONS.BAS" !+ ! External Routines !- EXTERNAL SUB lib$signal (long by value) EXTERNAL long function lib$get_foreign (string by desc) EXTERNAL long function lib$find_file_end (long by ref ) EXTERNAL long function lib$find_file (string by desc, & string by desc, & long by ref, & string by desc, & string by desc ) !+ ! MAP Declarations !- MAP (session) String Session_id = 16 MAP (form_name) String form_name_string = 255 MAP (form_file) String form_file_string = 255 MAP (command_line) String command_line_string = 255 MAP (string_1) String RTL_Image_1 = 35 MAP (string_2) String RTL_Image_2 = 35 MAP (control_text) String control_text_string = 5 !+ ! Local Variables !- Declare Integer forms_status Declare Integer file_status Declare Integer char_pos Declare Integer control_text_pos Declare Long send_control_text_count Declare Long command_line_length Declare Long form_name_length Declare Long find_file_context Declare String resultant_form_file_string RECORD item_list_entry_type VARIANT CASE WORD length WORD code LONG buff_addr LONG addr_length_returned CASE INTEGER end_list END VARIANT END RECORD item_list_entry_type DECLARE item_list_entry_type item_list(2) !+ ! The default form file name, if none is specified ! on the command line !- form_name_string = "FORMS$DEMO_FORM" !+ ! Get the command line, and get the name of the form ! file to use !- forms_status = lib$get_foreign (command_line_string by desc) command_line_length = len(command_line_string) if command_line_string = "" then goto enable_form end if ! ! remove leading/trailing spaces (8) ! make multiple spaces single (16) ! command_line_string = edit$(command_line_string,8+16) !+ ! Get the control text, if any !- control_text_pos = instr(1, command_line_string, " ") if control_text_pos > 0 then form_name_length = control_text_pos - 1 control_text_string = right$(command_line_string, control_text_pos+1) send_control_text_count = 1 else form_name_length = len(command_line_string) send_control_text_count = 0 end if !+ ! Get the form file, as specified on command line !- form_name_string = left$(command_line_string,form_name_length) enable_form: !+ ! Find the file. First, we look for an .EXE file. ! Second, we look for a .FORM file (since it is slower). !- file_status = lib$find_file( form_name_string, & resultant_form_file_string, & find_file_context, & ".EXE", & "SYS$DISK:[]" ) If (file_status AND 1%) = 0% Then file_status = lib$find_file_end( find_file_context ) file_status = lib$find_file( form_name_string, & resultant_form_file_string, & find_file_context, & ".FORM", & "SYS$DISK:[]" ) End If file_status = lib$find_file_end( find_file_context ) form_file_string = resultant_form_file_string !+ ! Build the name of the form file and the Form name ! according to conventions for demo files. !- ! ! Ideally, at this point we'd do a $PARSE to get the file-name ! portion of the filespec. Instead, we look thru the filespec ! by hand, throwing away the parts we don't need. ! ! ! Strip off device, node, and directory ! char_pos = instr(1, form_name_string, ":" ) While char_pos > 0 form_name_string = right$(form_name_string, char_pos+1) char_pos = instr(1, form_name_string, ":" ) next char_pos = instr(1, form_name_string, "]" ) While char_pos > 0 form_name_string = right$(form_name_string, char_pos+1) char_pos = instr(1, form_name_string, "]" ) next char_pos = instr(1, form_name_string, ">" ) While char_pos > 0 form_name_string = right$(form_name_string, char_pos+1) char_pos = instr(1, form_name_string, ">" ) next ! ! Strip off file type and version ! char_pos = instr(1, form_name_string, "." ) While char_pos > 0 form_name_string = left$(form_name_string, char_pos-1) char_pos = instr(1, form_name_string, "." ) next char_pos = instr(1, form_name_string, ";" ) While char_pos > 0 form_name_string = left$(form_name_string, char_pos-1) char_pos = instr(1, form_name_string, ";" ) next ! ! Strip off "FORMS$" if it's there ! If left$(form_name_string,6) = "FORMS$" then Form_name_string = right$(form_name_string,7) end if !+ ! Build an item list to pass in the enable call ! ! The Demo forms can call STR$* and LIB$* routines directly ! as procedural escapes when we include the names of those ! shareable images in the enable call ! ! To include more images, simply add another item list entry ! and include the name of another image. !- RTL_Image_1 = 'LIBRTL' item_list(0)::length = LEN(RTL_Image_1) item_list(0)::code = forms$k_image item_list(0)::buff_addr = LOC(RTL_Image_1) RTL_Image_2 = 'FORMS$MANAGER' item_list(1)::length = LEN(RTL_Image_2) item_list(1)::code = forms$k_image item_list(1)::buff_addr = LOC(RTL_Image_2) item_list(2)::end_list = 0 !+ ! Actually enable the form, letting the form do all that it can ! before returning to us. !- forms_status = forms$enable & (forms$ar_form_table, & "FORMS$DEFAULT_DEVICE" by desc, & Session_id by desc, & form_file_string by desc, & form_name_string by desc, & ,, & control_text_string by desc, & send_control_text_count by ref, & ,, & item_list(0)) !+ ! We now test the status value returned. ! ! A value of 1 means the call was successful. ! ! Any other value is some kind of error which we will report. !- IF (forms_status AND 1%) = 0% THEN print "Error in form enable:" EXIT PROGRAM forms_status END IF forms_status = forms$disable & (Session_id by desc) IF (forms_status AND 1%) = 0% THEN print "Error in form disable:" EXIT PROGRAM forms_status END IF END PROGRAM