TmListGetMethod Function

Returns the procedure name associated with the specified list method name.

Usage

procedure_name = TmListGetMethod(tool_name, list_name, method_name) 

Input Parameters

tool_name—A string specifying the unique name of a VDA Tool.

list_name—A string specifying the unique name of a list.

method_name—A string specifying the name of a method.

Returned Value

procedure_name—A string containing the name of the list method procedure if set, otherwise a NULL string is returned.

Keywords

None.

Discussion

The default list method names and their procedures are listed in Default List Methods and Procedures.

Default List Methods and Procedures

Description

Method Name

Method Procedure

Extend a list

TM_LIST_EXTEND

TmListExtend

Append to a list

TM_LIST_APPEND

TmListAppend

Insert in a list

TM_LIST_INSERT

TmListInsert

Retrieve from a list

TM_LIST_RETRIEVE

TmListRetrieve

Replace a list element

TM_LIST_REPLACE

TmListReplace

Delete (Undo) previous change to a list

TM_LIST_DELETE

TmListDelete

Clear list elements

TM_LIST_CLEAR

TmListClear

Destroy list elements

TM_LIST_DESTROY

TmListDestroy

Note:

Code for the default list method procedures are contained in the file, where WAVE_DIR is the the main PV‑WAVE directory.

WAVE_DIR/lib/vdatools/tmlist.pro
WAVE_DIR\lib\vdatools\tmlist.pro

Use TmListSetMethod to override the default method procedures.

Example

In this example, a user-defined TM_LIST_APPEND method is called. The method adds all items except the string 'Dont_Add'.

; Create the method procedure. 
PRO MyListAppend, tool_name, list_name, item
   DECLARE FUNC, TmGetAttribute
   DECLARE FUNC, TmSetAttribute
   items = TmGetAttribute(tool_name, list_name, 'ITEMS')
   free = TmGetAttribute(tool_name, list_name, 'FREE')
   IF free GE N_ELEMENTS(items) THEN BEGIN
      TmListExtend, tool_name, list_name
      items = TmGetAttribute(tool_name, list_name, 'ITEMS')
   ENDIF
   IF item NE 'Dont_Add' THEN BEGIN
      items(free) = item
      s = TmSetAttribute(tool_name, list_name, 'ITEMS', items)
      s = TmSetAttribute(tool_name, list_name, 'FREE', free+1)
   ENDIF
END
; Create a list and append to it. 
list_name = TmList(tool_name)
TmListSetMethod, tool_name, list_name, 'TM_LIST_APPEND', $ 
   'MyListAppend'
TmListAppend, tool_name, list_name, 'First Item'
INFO, TmListRetrieve(tool_name, list_name), /Full
; PV-WAVE prints the following: 
; <Expression>    LIST      = List(1)
; STRING    = 'First Item'
; TmListAppend, tool_name, list_name, 'Dont_Add'
INFO, TmListRetrieve(tool_name, list_name), /Full
; PV-WAVE prints the following: 
; <Expression>    LIST      = List(1)
; STRING    = 'First Item'
; Use TmListGetMethod to access the name of the method and 
; execute it explicitly.
new_var = 'Second Item'
var_name = 'new_var'
method = TmListGetMethod(tool_name, list_name, 'TM_LIST_APPEND')
INFO, method
; PV-WAVE prints: METHOD          STRING    = 'MyListAppend'
s = EXECUTE(method + ', tool_name, list_name, ' + var_name)
INFO, TmListRetrieve(tool_name, list_name), /Full
; PV-WAVE prints the following: 
; <Expression>    LIST      = List(2)
; STRING    = 'First Item'
; STRING    = 'Second Item'

See Also

TmList, TmListSetMethod