Macro Language Reference > Macros > System > getvar
  
getvar
Description
Allows you to extract system information from PTC ALD about the user's setup. This information can be used in many situations, for example assessing the state of the current document, the values of items currently in format, or the results of conditional formatting tests. The getvar code is a sequence of five digits used by PTC ALD to identify setup and document-specific items (system variables).
 
Example 232. Place value of getvar into another variable
The getvar code for the 'current text stream name' is 11520. The syntax shown below gets the current text stream name and places it in a variable called ^name:
getvar 11520,"name"
 
Example 233. Find getvar codes and place into variables
The getvar codes for the size of the current text stream and the cursor position in the current text stream are 21521 and 21522 respectively. The macro shown below gets these variables and places them in two variables called ^s and ^p:
getvar 22521,"s","p"
 
Example 234. Insert current filename at the current cursor position
You can use getvars to insert variable text in your text stream. The example below inserts the current filename into your text stream:
tshow "$11500v"
The diagnstc.3d file supplied with PTC ALD is a good example of a text composed almost entirely of show strings using getvar codes.
Syntax
getvar ( data type:n how many:n data group:n item number:n string number:n ) variable:s?
data type
The type of data that will be retrieved by getvar. The currently defined types are:
0
Word: a value in the range -32768...32767
1
String: a character string such as a filename
2
Length or size: a value or size in the range 2147483647... 2147483648. Sizes are retrieved in units of 0.0001mm.
3
String: up to 80 characters from a numbered string in one of PTC ALD strings files or a string defined with defstr or addstr. This data type is always followed by a how many of 1, and then by a string number, e.g. 31086 which will get the PTC ALD version number from string number 86. The data group and item number parameters are not used.
how many
The number of values to "get": the first value is that of the code listed in the macro, the second and subsequent values are those of the next consecutively numbered items in the list of getvar codes.
1..9
You can get up to 9 variables using a single getvar macro provided they belong to the same group (i.e. have a common third digit) and are consecutively numbered. In the list of getvar codes the second digit is always 1. If you need to get more than one value, change this to 2 or more (up to 9).
data group
Used with data types 0..2, the third digit of a getvar code tells PTC ALD which group to look at. PTC ALD getvar codes are organized in five groups, each of which can contain up to 100 items numbered from 0 to 99.
item number
The last 2 digits of a getvar code specify a precise item number that identifies the data retrieved by getvar. Related items are kept together so that they can be retrieved with a single getvar command (see how many). Not all item numbers are used - gaps in the numbering are left for future expansion.
string number
A three digit number representing a numbered string in one of PTC ALD strings files or a string defined with defstr or addstr.
variable
The name(s) of one or more variable(s) in which you wish to store this information. The variable names that store the requested values have to appear inside double quotes, but do not have the leading ^ symbol.
Additional Information
In most scripts using wdb to get setup information is far simpler, although using getvar gives your script access to a number of items for which dialog boxes do not exist, such as a user's command-line parameters, screen pixel width and height, mouse position etc. It is also not sensitive to the order in which dialog boxes are constructed.
A full list of PTC ALDgetvar codes can be accessed through any of the show strings dialog boxes, or with the macro wmnx 800.
 
It is worth remembering that show strings can be used to display the first 79 characters of a numbered string, e.g. <?show $31005v> would display the first 79 characters of string number 5 ('{manuals}clip') on the page. This feature can be quite useful if you are using defstr or addstr to define a string and want to check on how the string is being written.