Home page Home page Home page Home page
Pixel
Pixel Header R1 C1 Pixel
Pixel Header R2 C1 Pixel
Pixel Header R3 C1 Pixel
Pixel
By Sprezz | Tuesday 12 May 2020 16:15 | 0 Comments
Our last blog article dealt with promoting a help event so that dictionary help could be displayed when the user pressed F1 on a prompt. This was well received but it was pointed out that the technique crashed and burned when used from a multi-column edit table.

The reason for this is obvious - if an edit table has more than one column then it will logically also have more than one data dictionary item associated with it. So we need to determine which edit table column we are currently on and use this information to determine the correct dictionary item to use.

When we ask for the COLUMN property of an edit table, what we are provided with is a sub-value mark delimited array of all of the columns in the edit table. (The reason for this using such an unusual delimiter is simply that the columns property is derived from a larger array maintained by the system behind the scenes - the "control semantics"). Then to establish what column we're currently on we simply get the DEFPOSPROP property. (We could just get the CARETPOS property - but having been bitten once by not considering all possible permutations, we're now allowing for the possibility that a custom OLE control (which supports multiple columns) might not expose the current column using CARETPOS. So we use DEFPOSPROP which will always return the current column position regardless of how it is exposed. This assumes that the OLE control has been configured correctly using the New OLE Entity window described in this blog entry).

So without further ado we present the revised promoted event script!


0001     $Insert DICT_EQUATES
0002  
0003     ! table       = @ctrlEntId->table
0004     ! column      = @ctrlEntId->column
0005     table       = Get_Property( ctrlEntId, "TABLE" )
0006     column      = Get_Property( ctrlEntId, "COLUMN" )
0007  
0008     If Index( column, @Svm, 1 ) Then
0009        /*
0010           This is an edittable so we need to get the column
0011           currently selected
0012        */
0013     
0014        ! currentPos   = @ctrlEntId->defposprop< 1 >
0015        currentPos = Get_Property( ctrlEntId, "DEFPOSPROP" )< 1 >
0016        If currentPos >= 1 then
0017           column      = column<0, 0, currentPos >
0018        End
0019     End Else
0020        currentPos = 1
0021     end
0022  
0023     /*
0024        have we already read the help? If so then 
0025        just retrieve the cached version using a custom
0026        property (defined by using any word with an @ 
0027        at the beginning)
0028     */
0029   
0030     ! helpText = @ctrlEntId->$@HelpText< currentPos >
0031     fullHelpText = Get_Property( ctrlEntId, "@HELPTEXT" )
0032     helpText       = fullHelpText< currentPos >
0033  
0034     If helpText else
0035        helpText =  Xlate("DICT." : table, column, DICT_DESC$, "X")
0036        fullHelpText< currentPos > = helpText
0037        ! @ctrlEntId->$@HelpText = helpText
0038        call set_Property_Only( ctrlEntId, "@HELPTEXT", fullHelpText )
0039     End
0040     
0041     If Len( helpText ) Else
0042        helpText = "No dictionary help has been entered for column " : column
0043     End
0044  
0045     msgDef = helpText
0046  
0047     call Msg( @Window, msgDef, "ZZ_HELP" )
0048  
0049  return 0

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]



<< Home

Pixel
Pixel Footer R1 C1 Pixel
Pixel
Pixel
Pixel