Search and Navigation Method for VIEWTABLE

This code is also available in: Deutsch Español Français
Difficulty Level
Beginner
Published on :
The `execcmd` method overrides the parent method to provide custom search and navigation functionality. It processes 'FINDU' commands to search in the `usubjid` column, 'FINDS' to search in the `subject` column, and 'GOTO' to move to an absolute row. If the command is not recognized, it is passed to the parent method (`super`) for standard processing. The code contains a commented section that suggests a more generic search functionality ('FINDF') that has been disabled.
Data Analysis

Type : EXTERNE


The code does not load any data. It operates on an existing dataset that is displayed in a VIEWTABLE component. The origin of this data is not specified in this code snippet and is assumed to be provided by the application's execution context.

1 Code Block
METHOD
Explanation :
This block defines the `execcmd` method within an SCL (SAS Component Language) class. It uses a series of `if/else if` conditions to intercept and process specific commands (`inCmd`). For 'FINDU' and 'FINDS', it constructs a search condition string and calls the `_findRow` method of the current object (`_self_`). For 'GOTO', it converts the argument to a number and calls `_gotoAbsoluteRow`. For any other command, it uses `call super()` to invoke the parent method's implementation. The `retCode` variable is set to 1 to indicate that the command was successfully processed by this method.
Copied!
1execcmd: method
2 
3 inCmd :char
4 RETCODE :num
5 
6 optional=outCmd:char
7;
8*------------------- Find USUBJID --------------------;
9IF upcase(incmd)='FINDU' THEN DO;
10 IF ^missing(outCmd) THEN DO;
11 findlist = 'find(usubjid,"'||strip(outCmd)||'")';
12 _self_._findRow(findlist);
13 END;
14 
15 /* let VT know that we processed the command */
16 RETCODE = 1;
17END;
18 
19*------------------- Find SUBJECT --------------------;
20ELSE IF upcase(incmd)='FINDS' THEN DO;
21 IF ^missing(outCmd) THEN DO;
22 findlist = 'find(subject,"'||strip(outCmd)||'")';
23 _self_._findRow(findlist);
24 END;
25 
26 /* let VT know that we processed the command */
27 RETCODE = 1;
28END;
29 
30*------------------- Find SUBJECT --------------------;
31/* else if upcase(incmd)='FINDF' then do;
32 if ^missing(outCmd) then do;
33 matchvar = scan(outCmd,1);
34 matchval = scan(outCmd,-1);
35 if find(outCmd,'=') then do;
36 if _self_._getColumnAttribute(matchvar,'TYPE') ='C' then findlist = strip(matchvar)||'="'||strip(matchval)||'"';
37 else findlist = strip(matchvar)||'='||strip(matchval);
38 end;
39 else do;
40 findlist = 'find('||strip(matchvar)||',"'||strip(matchval)||'")';
41 end;
42 _self_._findRow(findlist);
43 end; */
44 
45 /* let VT know that we processed the command */
46/* retCode = 1;
47end; */
48*------------------- Goto Specific row --------------------;
49ELSE IF upcase(incmd)='GOTO' THEN DO;
50 
51 obs=INPUT(outCmd, 12.);
52 
53 IF obs > 0 THEN _self_._gotoAbsoluteRow(obs);
54 
55 /* let VT know that we processed the command */
56 RETCODE = 1;
57END;
58 /* otherwise, if command ne 'GOTO' let VIEWTABLE */
59 /* try to process it */
60ELSE call super(_SELF_, '_execCommand', inCmd, RETCODE, outCmd);
61 
62_self_=_self_;
63endmethod;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.

Related Documentation

Aucune documentation spécifique pour cette catégorie.