Operating System - OpenVMS
1752789 Members
6002 Online
108789 Solutions
New Discussion юеВ

Re: Creating Global Symbol In PHP?

 
Robert Atkinson
Respected Contributor

Creating Global Symbol In PHP?

I'm trying to create a global symbol in a PHP program, like this :-



It looks like the exec() creates it's own context, as I can't see anything when I do $ show symbol test_var.

Anyone know of a way to create a symbol available back at DCL?

BTW, I already know I can do $ DEFINE/JOB TEST_VAR value instead, but I want this to be compatible with existing procedures :)

Rob.
4 REPLIES 4
Wim Van den Wyngaert
Honored Contributor

Re: Creating Global Symbol In PHP?

Last solution : write it to a file and @ the file before you need the value ?

The openvms extentions I have don't mention anything about symbols.

Wim

Wim
Hoff
Honored Contributor

Re: Creating Global Symbol In PHP?

This looks to be the php variant of the classic DCL spawn "where'd my symbols go?" question; spawn gets you a new process context, and symbols and process logical names don't come back to the parent from that subprocess.

I don't see a PEAR package or such that matches DCL or OpenVMS or VMS over at php.net, and I don't see a listing of what's in the CSWS_PHP package. (The specific implementation of the php_openvms pieces inside that should give you a start, if there's not a solution there for you already.)

If you end up writing (or extending) the php_openvms pieces, that should be able to give you access to lib$set_symbol or such; the calls that are needed to modify the DCL symbol tables (or process logical name tables, via lib$set_logical) in the current process context.
Robert Atkinson
Respected Contributor

Re: Creating Global Symbol In PHP?

Looks like it :-

function_entry openvms_functions[] = {
PHP_FE(openvms_cvt_filename, NULL)
PHP_FE(openvms_getdvi, NULL)
PHP_FE(openvms_getjpi, NULL)
PHP_FE(openvms_getsyi, NULL)
PHP_FE(openvms_message, NULL)
PHP_FE(openvms_status, NULL)
PHP_FE(openvms_time, NULL)
PHP_FE(openvms_uptime, NULL)
{NULL, NULL, NULL}
};

I think the logical translation is probably more transparent than running the command file, but both require code changes.

Looking at the size and complexity of the existing functions, it would probably be very easy to add a DCL Symbol routine, but plugging anything into the current version and trying to compile it seems to be a minefield!

Lets hope the v5 release has some extra VMS functionality to it.

Rob.
Robert Atkinson
Respected Contributor

Re: Creating Global Symbol In PHP?

In fact, it's probably as easy as this :-

#ifdef __VMS
struct dsc$descriptor_s symbol_name_desc;
struct dsc$descriptor_s symbol_value_desc;


symbol_name_desc.dsc$w_length = strlen("ICALC_OUT");
symbol_name_desc.dsc$a_pointer = "ICALC_OUT";
symbol_name_desc.dsc$b_class = DSC$K_CLASS_S;
symbol_name_desc.dsc$b_dtype = DSC$K_DTYPE_T;

#endif


#ifdef __VMS
symbol_value_desc.dsc$w_length = strlen(symbol_value);
symbol_value_desc.dsc$a_pointer = symbol_value;
symbol_value_desc.dsc$b_class = DSC$K_CLASS_S;
symbol_value_desc.dsc$b_dtype = DSC$K_DTYPE_T;
LIB$SET_SYMBOL(&symbol_name_desc,&symbol_value_desc);
#endif


(Caught Hoff's post after I wrote this!)