Salesforce

How Do I Share Variables Amongst Contexts? (Magic xpa 3.x)

« Go Back

Information

 
Created ByKnowledge Migration User
Approval Process StatusPublished
Objective
Description

How Do I Share Variables Amongst Contexts? (Magic xpa 3.x)

With a single-context environment, are commonly shared by putting them in the Main Program, or by using the SetParam() function. However, neither of these options works between contexts. In the example above, each window can store values within its own context using SetParam() and GetParam(). But in order to get two or more contexts to look at the same set of values, the SharedValSet() and SharedValGet() functions need to be used.

Using SharedValSet()

The syntax is:

SharedValSet(<name>,<value>)

where:

<name> is the name of the variable. This can be a hard-coded string in quotes, or a variable as in the example above.

<value> is the value of the variable, which will be stored. This can be a variety of data types, but it is up to you to make sure that when you fetch it, you fetch it into the correct data type. For instance, if you store a date, you should fetch it back into a date, although Magic xpa will attempt to do the conversion based on the stored data type.

The function always returns TRUE.

Using SharedValGet()

The syntax is:

SharedValGet(<name>)

where:

<name> is the name of the variable. This can be a hard-coded string in quotes, or a variable as in the example above.

The function returns the value of the variable as it exists in Magic xpa’s memory.

Hint: The shared values show up on the variable list of the debugger, at the top of the list.

See also

The Online Samples project (program MT07)

Reference
Attachment 
Attachment