KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Creating and Setting Variables with the 4D Plugin API
PRODUCT: 4D | VERSION: 6.7 | PLATFORM: Mac & Win
Published On: August 3, 2001

When using the 4D API to create and then use a variable there are two to three steps that need to be taken. The first step is to create the variable with PA_CreateVariable.

Ex.

PA_Variable vLong;

vLong = PA_CreateVariable(eVK_Longint, 0);

Now by default the value of vLong is zero. When calling PA_CreateVariable numerics are zero, strings are empty, and an array has a zero elements. If you want to change the value of the new variable you need to call PA_SetxxxVariable where "xxx" is the variable type. In our above example we would use PA_SetLongintVariable.

PA_SetLongintVariable(vLong, 1000);

Now comes the important step that some may forget. You must call PA_SetVariable for the new change to take place, and for 4D to know that the variable has been updated.

PA_SetVariable("vLongint", vLong, 1);

"vLongint" is the name we are giving for our new Variable. Now when you run 4D you can use the variable "vLongint" in your code. When creating and setting a variable in a plug-in to be used in 4D remember the important step of calling PA_SetVariable.

For more information on Creating and Setting Variables please look at the 4D Plug-In Reference.pdf starting on page 773.

http://www.4D.com/SDK

Commented by Randy Shepherd on February 24, 2010 at 3:09 PM
Where can I get the 4D Plun-In Reference.pdf? The link on this posting is no longer valid?