Pregunta

I am trying to pass values from a C++ program on VMS.

$DESCRIPTOR( lname, (char*) "A" );
$DESCRIPTOR( lvalue, (char *) "Hello World" );
lib$set_logical( &lname, &lvalue );
lib$set_symbol (&lname,&lvalue);

Should it work? If Not how do I correct it?

How can I check the return-values?

How can I check in the environment if it succeeded?

If it works, is it reliable? (Not depending on permissions etc).

¿Fue útil?

Solución

No. Check out how $DESCRIPTOR is defined, in descrip.h: #define $DESCRIPTOR(name,string) struct dsc$descriptor_s name = { sizeof( string)-1, DSC$K_DTYPE_T, DSC$K_CLASS_S, string }

In your example the first element of lname and lvalue will both contain 3, derived from the size of (char*), however expected is the length of the string, derived from the size of a character array.

Otros consejos

Working examples in C for lib$set_symbol and lib$set_logical, including how to do descriptors correctly and standardised error checking. You need no privileges to perform these functions, so yes, it's "reliable".

To see the results of the programs, you would type (for my examples):

$ SHOW SYMBOL/GLOBAL LIB_SET_SYMBOL_TEST

and:

$ SHOW LOGICAL LIB_SET_LOGICAL_TEST
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top