1.4.1. Creating an RP Variable

To create a new RP variable in Scheme, you must use the macro (rp-var-define). For example, the following command creates an integer RP variable named myInt with the default value of 1.

(rp-var-define 'myInt 1 'integer #f)

Note:  Symbols are usually used as arguments in Scheme functions rather than strings. To learn more about symbols, see Symbols.


Before you create an RP variable, it is good practice to check that an RP variable by that name has not already been defined. One simple way to do this is to create a function, called make-new-rpvar, which checks the presence of a RP variable by that name before creating one. The make-new-rpvar function below can be copied into your Scheme file and used to make sure that no RP variables of the names you have chosen already exist before you create them.

(define (make-new-rpvar name default type)
  (if (not (rp-var-object name))
    (rp-var-define name default type #f)))

(make-new-rpvar 'myInt 1 'integer)

Release 18.2 - © ANSYS, Inc. All rights reserved.