On the Natural site it is clear but i think we have talk past each other.
I am working with the INTERFACE 4 C API.
Here a short example program:
Natural site:
define data local
1 returncode (B4)
1 index (I2)
1 index2 (I2)
1 testarray (A/1:20/1:30) DYNAMIC
end-define
for index = 1 to 20
for index2 = 1 to 30
move "ffff" to testarray(index, index2)
end-for
end-for
call INTERFACE4 "PRALL" testarray
compute returncode = ret("PRALL")
write returncode
end
C site:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "natuser.h"
long read_vars(WORD nparm, void *parmhandle, void *traditional)
{
void *value;
FILE *fp;
struct parameter_description var_info;
if((fp = fopen("tmp/natvars", "w")) == NULL)
return((long)1);
if(ncxr_get_parm_info(0, parmhandle, &var_info) < 0)
{
fprintf(fp, "Error reading var infos\n");
fclose(fp);
return((long)2);
}
if((value = malloc(sizeof(char)*var_info.length_all)) == NULL)
{
fprintf(fp, "%s\n", strerror(errno));
fprintf(fp)
return((long)3);
}
if(ncxr_get_parm(0, parmhandle, var_info_length, value) < 0)
{
fprintf(fp, "Error reading var value\n");
fclose(fp);
return((long)4);
}
logHexDump(value, var_info.length_all, fp);
fprintf(fp, "Format: [%c(%d)]\n", var_info.format, var_info.format);
fprintf(fp, "Length VP: [%d]\n", var_info.length);
fprintf(fp, "Length BY: [%d]\n", var_info.byte_length);
fprintf(fp, "Length AP: [%d]\n", var_info.precision);
fprintf(fp, "Length ALL: [%d]\n", var_info.length_all);
fprintf(fp, "Dimensios: [%d]\n", var_info.dimensions);
free(value);
fclose(fp);
return((long)0);
}
As i said previously the entrys length, precision, byte_length and length_all in the parameter_description structure are all set to zero so i don’t know how much memory i have to allocate to copy the array data in my program.