In regards to Dr R:> comments on point:

03.     Make sure to pre-define all global variables used in forms with
        appropriate data type.
I saw a lot of this when I was first diving into the RBWin world so I
come up with this little snippet and enhanced it just the other day with
some of the new syntax features:

*(
--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
    PROGRAM NAME: getvars.rmd

          AUTHOR: Jim Limburg
                  Tuftco Corporation
                  2318 Holtzclaw Ave, Chattanooga, TN 37404
                  Voice: 423-698-8601 Fax: 423-698-0842
                  email: [EMAIL PROTECTED] --business
                         [EMAIL PROTECTED] --home

         PURPOSE: Capture the variables needed to run a form.
                  Will set the clipboard to a list of SET VAR
                  statements that a form needs to have preset
                  before running

       IS RUN BY: Be connected to the database you are working
                  with and then type at R> prompt:  RUN getvars.rmd
                  Run the First Step and Quit. This will tell you
                  to Open the form in design mode -- Do this by
                  going to the Manager where reports,forms,and
                  tables are created and go to the forms tab and
                  click on (highlight) the form  you are working on
                  and click the design button. Immediatly close the
                  form (yes without doing anything) and then
                  RUN getvars.rmd again and choose the second
                  option and Quit. Now you can (paste) the SET VAR
                  statements this creates into your code pressing
                  [CTRL] + [V] or right click place you want the
                  code to be placed and choose paste, or choose paste
                  from the menu option you have in the program you
                  are writing code to.

         RETURNS: Sets the Clipboard to a list of variables
                  that can be pasted into your code before a form call.
                  This list of variables will already be predefined
                  to the proper datatype as what you have defined in
                  the form.

    MODIFICATION HISTORY
             Created:   02/12/2002

            Modified:   12/31/2002 -- Put all the code into one file
                                   -- and used new Choose #LIST commmand
                                   -- so there is no need to have a dummy
                                   -- table in the database.

 --=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
 )

LABEL lbtop
*(CHOOSE vaction FROM #VALUES FOR ('1. Run Step One'), '1' FROM dummy +
UNION SELECT ('2. Run Step Two'), '2' FROM dummy +
UNION SELECT ('3. Quit'), '3' FROM dummy +
AT 15 CENTER TITLE 'Choose Next Action')
CHOOSE vaction FROM #LIST '1. Run Step One,2. Run Step Two,3. Quit' +
AT 15 CENTER TITLE 'Choose Next Action'
--SWITCH (.vaction)
SWITCH ((SGET(.vaction,1,1)))
  CASE 1
    CLEAR ALL VARIABLES
    SET ERROR VARIABLE errvar
    CHOOSE vm_formname FROM #FORMS
    IF errvar = 0 AND vm_formname IS NOT NULL AND vm_formname <> '[Esc]' THEN
        SET VAR vm_msg1 TEXT = ('Be sure to Open ' + .vm_formname)
        SET VAR vm_msg2 TEXT = (' form in Design mode, and close it.')
        SET VAR vm_msg TEXT = (.vm_msg1 + .vm_msg2)
        PAUSE 1 USING .vm_msg AT CENTER CENTER
    ENDIF
    CLEAR VAR vm_ms%
    CLS
    BREAK
  CASE 2
    IF vm_formname <> '[Esc]' THEN
        CLEAR VAR vm_formname,errvar
        OUTPUT formvars.lst
        SHOW VAR
        OUTPUT SCREEN
        DROP TABLE frmvars
        CREATE TABLE frmvars (varname TEXT 20, varvalue TEXT 42, vartype +
        TEXT 10)
        LOAD frmvars FROM formvars.lst +
        AS FORMATTED USING varname 1 18, varvalue 22 61, vartype 62 72
        CLS
        *(This is where it parses the information it has gathered from the
          table and creates the file to hold the SET VAR statements.)
        SET VAR vm_vars NOTE = NULL
        SET ERROR MESSAGES 2077 OFF
        ERASE frmvars.txt
        SET ERROR MESSAGES 2077 ON
        SET ERROR MESSAGES 705 OFF
        DROP CURSOR curs1
        SET ERROR MESSAGES 705 ON
        DECLARE curs1 SCROLL CURSOR FOR SELECT varname, vartype FROM frmvars
        OPEN curs1
        FETCH FIRST FROM curs1 INTO vm_vname IND vi_1, vm_vtype IND vi_2
        SET VAR vm_vnameshort TEXT = (SGET(.vm_vname,5,1))
        WHILE SQLCODE <> 100 THEN
          SWITCH (.vm_vnameshort)
            CASE '#DATE'
            CASE '#TIME'
            CASE '#PI  '
            CASE 'SQLCO'
            CASE 'SQLST'
            CASE '-----'
            CASE 'Varia'
              BREAK
            DEFAULT
              OUTPUT frmvars.txt APPEND
              WRITE 'SET VAR ' .vm_vname .vm_vtype '= ' 'NULL'
              OUTPUT SCREEN
              SET VAR vm_vars = (.vm_vars + 'SET VAR ' + .vm_vname + +
              ' ' +  .vm_vtype + ' = NULL' + (CHAR(13)) + (CHAR(10)))
              BREAK
          ENDSW
          FETCH NEXT FROM curs1 INTO vm_vname IND vi_1, vm_vtype IND vi_2
          SET VAR vm_vnameshort = (SGET(.vm_vname,5,1))
        ENDWHILE
        SET CLIPBOARD .vm_vars
        DROP CURSOR curs1
    ENDIF
    DROP TABLE frmvars
    SET ERROR MESSAGES 2077 OFF
    ERASE frmvars.txt
    SET ERROR MESSAGES 2077 ON
    CLEAR ALL VAR
    CLS
    PAUSE FOR 2 USING 'Variable Definitions copied to clipboard' +
    AT CENTER CENTER
    BREAK
  CASE 3
  CASE '[Esc]'
    CLEAR ALL VAR EXCEPT vm_formname
    GOTO lbexit
    BREAK
ENDSW
GOTO lbtop
LABEL lbexit
RETURN

Hope this helps some

Jim Limburg

Reply via email to