Steven

I have written a little cmd file that makes setting of variables before
running a form a bit easier..

It will work with version 6.5++ or 7. Because of the ability that when
we open a form in design mode Rbase declares all the vars behind the
scenes I wanted to take advantage of this. To run this file on a 6.5++
form type RUN frmvrlst.c2r at R:> and it will prompt you for the forms name.
Then pick '1. Run Step One' in the Choose menu. After this it should
prompt you to open the form in design mode, and then rerun by typing
RUN frmvrlst.c2r at R:> and pick '2. Run Step Two' after this close the
form in design mode and you can just ('PASTE', Crtl-V, Right-single-click
and choose Paste) to get the results of my code. What it will do is
get a list of all var listed in the 'Var List' for the form and then
alter then presetting them to NULL
Let's say you have a var declared as vf_myvar = (This - that) in the
form. Then it will write the var command out as SET VAR vf_myvar TEXT = NULL

Check it out.

Oh, P.S. To run this on version 7 you don't have to open the form in
design mode. RBTI was kind enough to enable this option to be able to
do it in code.

*(
--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
    PROGRAM NAME: frmvrlst.c2r

          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] --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 frmvrlst.c2r
                  This will prompt you for a form name from the list
                  of forms in the database. If running Rb7 at this
                  point it will then open this form in design mode.
                  Do it's work behind the scenes and copy the
                  variable list to the clipboard.
                  Then all you have to do is hit Ctrl-V to paste it
                  into a file.
                  If you are running RB6.5++ then you have to run
                  this in a two step process and open the form in
                  design mode when prompted between the two stages
                  of this process.

         RETURNS: Sets the Clipboard to a list of variables
                  that can be pasted into your code before a form call.

    MODIFICATION HISTORY
             Created:   11/18/2003
             RB Vers:   Works with RB7, and with 6.5++

 --=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=--=+=-
 )
SET CLIPBOARD ' '
SET VAR vm_instepprocess TEXT
IF vm_instepprocess <> 'Y' THEN
  CLEAR ALL VARIABLES
ENDIF
SET VAR vm_dbname TEXT = NULL
SET VAR vm_dbname = (CVAL('database'))
IF vm_dbname IS NOT NULL THEN
  CLEAR VAR vm_dbname
  SET VAR vm_formname TEXT = NULL
  SET ERROR MESSAGES OFF
  SET MESSAGES OFF
  SET ERROR VARIABLE errvar
  CHOOSE vm_formname FROM #FORMS
  IF vm_formname IS NOT NULL AND vm_formname <> '[Esc]' THEN
    SET VAR vm_rbver = (CVAL('version'))
    SET VAR vm_sloc = (SLOC((LUC(.vm_rbver)),'V7'))
    IF vm_sloc > 0 THEN
      SET VAR vm_mscmd TEXT = ('forms ' + ' ' + .vm_formname)
      &vm_mscmd
      CLS
      CLEAR VAR vm_ms%
    ELSE
      --If we get here then we are in another version 6.5 likely
      --but had better check
      SET VAR vm_sloc = (SLOC((LUC(.vm_rbver)),'V6.5'))
      IF vm_sloc > 0 THEN
        SET VAR vm_action TEXT = NULL
        CHOOSE vm_action +
        FROM #LIST '1. Run Step One,2. Run Step Two,3. Quit' +
        AT CENTER CENTER TITLE 'Choose Next Action' +
        CAPTION 'Run Options...' LINES 5 FORMATTED
        IF vm_action IS NOT NULL AND vm_action <> '[Esc]' THEN
          SWITCH (.vm_action)
            CASE '1. Run Step One'
              SET VAR vm_msg1 TEXT = ('Open' + ' ' + .vm_formname)
              SET VAR vm_msg TEXT = +
              (.vm_msg1 + ' ' + +
              'form in design mode, leave it open, and then run step two.')
              PAUSE FOR 11 USING .vm_msg CAPTION 'Instructions'
              CLEAR ALL VAR EXCEPT vm_formname
              SET VAR vm_instepprocess = 'Y'
              CLEAR VAR vm_action
              GOTO lbexit
              BREAK
            CASE '2. Run Step Two'2
              CLEAR VAR vm_action
              GOTO stp2
              BREAK
            CASE '3. Quit'
            CASE '[Esc]'
              CLEAR ALL VAR EXCEPT vm_formname
              GOTO lbexit
              BREAK
          ENDSW
        ENDIF
      ELSE
        PAUSE 2 USING 'This is only designed for version 6.5 or 7' +
        CAPTION 'Runtime error'
      ENDIF
    ENDIF
    LABEL stp2
    CLEAR VAR errvar
    CLEAR VAR vm_rbver,vm_sloc
    OUTPUT formvars.lst
    SHOW VAR
    OUTPUT SCREEN
    SET ERROR MESSAGES 2038 OFF
    DROP TABLE frmvars
    SET ERROR MESSAGES 2038 ON
    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 vm_v1, vm_vtype IND vm_v2
    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'
        CASE '     '
        CASE ' '
        CASE 'vm_fo'
        CASE 'vm_in'
          BREAK
        DEFAULT
          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 vm_v1, vm_vtype IND vm_v2
      SET VAR vm_vnameshort = (SGET(.vm_vname,5,1))
    ENDWHILE
    CLEAR VAR vm__v%
    IF vm_vars IS NOT NULL THEN
      SET CLIPBOARD .vm_vars
    ELSE
      PAUSE FOR 2 USING 'No variables for this form' CAPTION 'Information'
    ENDIF
    DROP CURSOR curs1
    DROP TABLE frmvars
    SET ERROR MESSAGES 2077 OFF
    ERASE frmvars.txt
    SET ERROR MESSAGES 2077 ON
  ENDIF
  --CLEAR ALL VAR
  CLS
  SET VAR vm_msg1 TEXT = ('Go ahead and close ' + .vm_formname)
  SET VAR vm_msg2 TEXT = (' form that has been opened in Design mode.')
  SET VAR vm_msg TEXT = (.vm_msg1 + .vm_msg2)
  PAUSE 1 USING .vm_msg CAPTION 'Instruction'
  CLEAR VAR vm_formname
ELSE
  PAUSE +
  FOR 2 USING 'Your not connected to a database' CAPTION 'Execution Error'
ENDIF
CLEAR ALL VAR
LABEL lbexit
SET ERROR MESSAGES ON
SET MESSAGES ON

RETURN

Steven Hoggan wrote:
Hello again,

For what it's worth, one of the biggest (by a long distance) culprits we
have managed to identify in terms of memory "eating" is a 3-table form that
we regularly call in an iterative loop. More often than not, memory is not
released/recovered when the form is exited, and we can find a 4GB swap file
used up pretty quickly.


This problem may or may not be anything to do with the current memory
discussion, but it's certainly a major problem for us.

It doesn't seem to happen to the same extent with straightforward
single-table forms, although this is something we are still testing.

In general, though,  does anyone have any general recommendations for
efficient form construction/call/release?

I'm thinking along the lines of (where possible) pre-setting all variables
prior to calling the form, rather than having the form do the lookups, etc.

Thanks

Steven







Privacy & Confidentiality Notice
----------------------

This message and any attachments thereto is confidential and intended solely
for the person to whom it is addressed. It may contain privileged and
confidential information. If you are not the intended recipient you must
not read, copy, distribute, discuss or take any action in reliance on it.
If you have received this information in error, please notify us as soon as
possible on the telephone number shown. Thank you. Fitzpatricks.


Tel:  +44 (0)141 306 9000
Fax:  +44 (0)141 306 9090
Web:  www.fitzpatricks.co.uk





Reply via email to