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.
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.
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.