version 2003
PA_GetVariable (vName) PA_Variable
| Parameter | Type | Description | |
| vName | char * | Name of process/interprocess variable to access | |
| Function result | PA_Variable | Value of the variable whose name is vName |
Description
The routine PA_GetVariable returns the content of the variable whose name is passed in vName.
To get the content of an interprocess variable, vName must start by the interprocess sign ("<>" under Windows or the diamond under MacOS)
If the 4D Plug-in attempts to access a non-existing variable, the PA_Variable data structure returned with a type = eVK_Undefined (this can be get by the PA_GetVariableKind routine) and PA_GetLastError returns eER_NoErr.
NOTE:
Depending on default settings and on previous calls to PA_UsePStrings or PA_UseCStrings, vName must be a Pascal or a C string.
IMPORTANT NOTE:
For Text, Picture, and BLOB, remember that the handles to the data of those structures belong to 4th Dimension. Do not dispose of it or call PA_ClearVariable.
Examples
(1) Checking the kind of a variable.
// We are waiting for a longint variable
PA_Variable aVar;
aVar = PA_GetVariable("\pmyPrivateVar"); // using Pstring on a Mac
if(PA_GetVariableKind(aVar) != eVK_Longint)
PA_Alert("\pI expected a long integer variable");
(2) Get the value of a system variable (OK).
char GetOK ()
{
PA_Variable ok;
char okValue = (char) 0;
// Note that in interpreted mode, OK may be undefined
ok = PA_GetVariable("OK"); // using C strings on Windows
if(PA_GetLastError() == eER_NoErr)
{
switch (PA_GetVariableKind(ok))
{
case eVK_Real:
if (PA_GetRealVariable(ok) != 0.0 )
okValue = 1;
break;
case eVK_Longint:
if (PA_GetLongintVariable(ok) != 0)
okValue = 1;
break;
}
}
return okValue;
}
See Also
Error Handling
Use PA_GetLastError to see if an error occurred.