Readers Clinic - Locating at a specific MV in an AMV Group

Published ByDateVersionKnowledge LevelKeywords
Sprezzatura Ltd01 JUL 19922.12+EXPERTAMV, MV, AMV_VARS, CURR_AMV_GROUP, AMV_DISPLAY

Mike Nourse of JM2 Systems Inc recently posed the following complicated query - " I have a single valued date prompt preceding an AMV group. The AMV group has a controlling date mv and three associated money mvs. My goal is to have the user enter the date in the single valued prompt and locate it or where it ought to be in the controlling AMV. Once a position is found, start to display the AMV group at that mv position. The group data will already be sorted in descending date order."

This task actually turned out to be more complicated than it at first appears. Referring back to WC_AMV_VARS% (Vol 2 Iss 9 Page 10) it seemed that all that needed to be done was to locate the correct position within the array and then set WC_AMV_VARS%< WC_CURR_AMV_GROUP%, AMV_DISPLAY$ > to this position, and set WC_AMV_ACTION% to 4 for "changed". However whenever this was done, the system automatically overwrote the AMV_DISPLAY$ setting, putting it back to 1 thus foiling the attempt. What was required was a way to force an AMV reset without resetting AMV_DISPLAY$. The code following achieves the result. The paragraph following the code explains how it works.

  Subroutine
  LocateInGroup
  /*
    Author   AMcA
    Date     June 92
    Purpose  This routine is designed to be called from the collector at the
             preprompt of a controlling MV of an AMV group. It takes the
             value of @Record<1> (change this for your requirements) and
             locates it in the current field in @Record, and realigns the
             entire grouped display at that point.
  */

  $Insert Include, Window_Common%
  $Insert Include, LCPositions
  $Insert Include, Window.Constants
  Value = @Record<1>

  /*
     Check the prompt register to see if  we have already done this value if
     so don't move. This prevents an infinite loop occasioned by using RESET
     on a preprompt. The disadvantage of this is that the MVs will only
     relocate the first time the value is changed.
  */
  If WC_SI%< PReg1 > = Value Then
    Null
  End Else
    CurrentField = @Record< WC_SI%< FNO > >
    Locate Value In CurrentField By "DR" Using @VM Setting Pos Else Null
    WC_SI%< PReg1 > = Value
    WC_MV% = Pos
    For X = 1 To WC_Amv_Vars%< WC_Curr_Amv_Group%, Amv.Width$ >
     Field = WC_W%( WC_Amv%< WC_Curr_Amv_Group%, X> )< FNO >
     * Add a dummy line
     @Record = Insert(@Record, Field, Pos, 0, "*")
    Next
    WC_Amv_Action% = Amv.Delete$
    * Set line to start display at
    WC_Amv_Vars%< WC_Curr_Amv_Group%, Amv.Display$ > = Pos
    * Tell window processor about the dummy line
    WC_Amv_Vars%< WC_Curr_Amv_Group%, Amv.Depth$> =
                 WC_Amv_Vars%< WC_Curr_Amv_Group%, Amv.Depth$> + 1
    WC_Reset% = Reset.Prompt$
  End
  Return

When in an associated MVed group, deleting a line leaves the cursor at the current MV position regardless of how far down the AMV group it is. Thus the answer was to set the correct position in MV and AMV_DISPLAY and to force a non-destructive delete. The latter might seem to be a non-sequitur but can be achieved by inserting a dummy row specifically for it to be deleted.

(Volume 4, Issue 3, Pages 6,7)

  • tips/revmedia/v4i3a4.txt
  • Last modified: 2024/06/19 20:20
  • by 127.0.0.1