The HotDocs Computation Archive
Get Extra Help

0133 - Asset Navigator

Description:

How to implement smart and quick navigation of repeated dialogs.


• Code •

DocInit-c Computation (located at very beginning of the document):

// Selects whether to start with first asset,
// jump to a specific asset, or jump to end of list
ASK ProceedMode-m
IF ProceedMode-m = "Start at Beginning"          // This is the default
   // do nothing
ELSE IF ProceedMode-m = "Jump to an Asset"
   JumpToAsset-c          // SETs JumpNum-n to the iteration number of the selected asset
   SET JumpOn-b TO TRUE
ELSE IF ProceedMode-m = "Jump to End"
   JumpToEnd-c          // Sets JumpNum-n to one more than the existing asset total
   SET JumpOn-b TO TRUE
END IF

// Presents the Asset Info dialog (or the desired asset)
ASK Asset Info

// Turns off jump mode for future passes
SET JumpOn-b TO FALSE

QUIT
 
 
JumpToAsset-c Computation (called by the DocInit-c computation):

// Creates asset selection list (JumpAssetList-m) and presents it to user;
// Then SETS JumpNum-n TO iteration number of selected asset
ASK NONE
CLEAR JumpAssetList-m
REPEAT Asset Info
   ADD "«ACN-n[Num]» - «AssetName[Num]»" TO JumpAssetList-m
   SET Num TO Num + 1
END REPEAT

ASK ALL
ASK JumpAssetList-m
SET JumpNum-n TO INTEGER( FIRST( JumpAssetList-m,3 ) )
SET JumpNum-n TO JumpNum-n - 300
ASK DEFAULT

QUIT
 
 
JumpToEnd-c Computation (called by the DocInit-c computation):

// Sets JumpNum-n variable to one more than the total of answered iterations
ASK NONE
ASK Asset Info  // run thru asset list just to return the total number
SET JumpNum-n TO COUNT( Asset Info ) + 1
ASK DEFAULT
QUIT
 
 
Script in the Asset Info dialog:

SET Num TO COUNTER

// Jump to a specified asset or to end of list
IF JumpOn-b = TRUE
   IF ProceedMode-m = "Jump to an Asset"
      IF Num != JumpNum-n
         HIDE ALL
      ELSE
         SET JumpOn-b TO FALSE
         SHOW ALL
      END IF
   ELSE IF ProceedMode-m = "Jump to End"
      IF Num < JumpNum-n 
         HIDE ALL
      ELSE
         SET JumpOn-b TO FALSE
      END IF
   END IF
END IF
QUIT

• Explanation •

Issue: What I wanted was to be able to jump to a specific previously-answered iteration of a repeated dialog. Example: In a repeat dialog gathering info about assets, if the user wants to edit the information about asset number 16 in a list of, say, 20 assets, it is tedious to have to click through assets 1 to 15 in order to get to number 16.

Solution: What I finally ended up with was some code that combines Bart Earl's for jumping to the end of the list (see Computation #0131: Fast-tracking Repeated Dialogs) and Jim Garrison's for jumping to a specific record (see Computation #0132: Record Look-up). In my case, it is a list of assets. I start with a m/c variable (ProceedMode-m) asking whether the user wants to start at the beginning of the list, jump to an asset, or jump to the end. If one of the jump options is selected, a number called JumpNum-n is populated with either (1) the iteration number of the asset selected, or (2) a number that is one more than the total number of assets already in the list. JumpNum-n is then used in the dialog script to control what records are hidden.

The DocInit-c variable, located at the beginning of the document, begins the process. It presents the ProceedMode-m variable and then, if one of the jump options is selected, it calls a separate computation variable, either JumpToAsset-c or JumpToEnd-c, to populate the JumpNum-n variable. I don't know why this is so, but I found that the routine would not work if all the code was in the DocInit-c variable itself; it was necessary to have some of it in separate variables.

The t/f variable JumpOn-b is used in the dialog script, to indicate when the HIDE commands should operate. It is turned on or off (TRUE or FALSE) by SET commands in the DocInit-c variable (and in the dialog script itself).

As Bart indicated, this allows you to jump to the desired record, hiding all the others; yet, once there, you can freely move bacward or forward to the other records which are no longer hidden. Can't beat that!

A final comment on the code in JumpToAsset-c: The SETting of the JumpNum-n variable looks more complicated than might be expected. This is because in our office system each asset is assigned a three digit asset control number. The first asset entered into the system becomes ACN301, the second, ACN302, etc. When the asset is ADDed to JumpAssetList-m, the ACN (the variable name is ACN-n) is placed in front of the asset name. When an asset is selected, the full ACN-n is first extracted as JumpNum-n, and then 300 is subtracted from it, to produce the asset's iteration number.

 

• Contributors •

ROBERT A. MARTIN
LAW OFFICES OF ROBERT A. MARTIN
1500 NEWELL AVENUE, SUITE 500
WALNUT CREEK CA 94596
Tel: 925/935-9935
Fax: 925/935-9971