[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

2228.0. "Using DWT$FETCH_SET_VALUES from ADA" by PEACHS::BELDIN () Wed Feb 07 1990 10:37

Any info on how to use DWT$FETCH_SET_VALUES from ADA?

When a user attempts to compile an ADA program calling DWT$FETCH_SET_VALUES he
gets a compilation error. He has traced this to the args argument passed to
this subroutine. According to the documentation args is a structure with two
elements  .name and.value. The .name portion is of the type DwtNxxxx usually
used as the tag in passing arguments. The second element of the structure is
suposed to be a string that gives the index to the literal in the UIL file that
you are trying to get at (at least thats what I think it is).

                                                                            
The documentation shows an example that looks like C - anybody know what the
ADA example would look like? I would hazzard a guess that it wants a pointer
to the string - which the C example would give him... 

Rick Beldin
3-1019 
T.RTitleUserPersonal
Name
DateLines
2228.1ULTRA::WRAYJohn Wray, Secure Systems DevelopmentWed Feb 07 1990 11:1432
    The type should be obvious from module DWT, in file
    SYS$LIBRARY:DECW$DWT_.ADA, and the Ada compiler should also have listed
    the type it was expecting when it tried to find a DWT$FETCH_SET_VALUES
    procedure whose signature matched the actuals.  The Ada compiler
    generates very helpful error messages, containing a lot of information.
    It's worth reading them.
    
    
    From SYS$LIBRARY:DECW$DWT_.ADA:
    
    procedure FETCH_SET_VALUES (
	STATUS		: out CARDINAL_TYPE;			-- return value
	HIERARCHY_ID	: in  DRM_HIERARCHY_TYPE;
	WIDGET		: in  WIDGET_TYPE;
	ARGS		: in  ARG_ARRAY_TYPE;
	NUM_ARGS	: in  CARDINAL_TYPE);
 
    ARGS is an ARG_ARRAY_TYPE, which is defined as follows:
    
    type ARG_ARRAY_TYPE is array (NATURAL range <>) of ARG_TYPE;
    
    where
    
    type ARG_TYPE is
	record
	    ARG_NAME	: STRNG_TYPE;				--  ptr to actual chars 
	    ARG_VALUE	: ARG_VAL_TYPE;				--  index into arglist
	end record;
    
    So your user needs an array of ARG_TYPEs, not a single one.
    
    John
2228.2ARG_VAL_TYPE the issue, not ARGS...PEACHS::BELDINWed Feb 07 1990 12:2845
Re .1

>    type ARG_TYPE is
>        record
>            ARG_NAME    : STRNG_TYPE;		--  ptr to actual chars 
>            ARG_VALUE   : ARG_VAL_TYPE;        --  index into arglist
>        end record;
>    

I guess the question should be restated in that how do you specify items
for the ARG_VALUE field of the ARG_TYPE record.  On page 4-16 of the
DECwindows Programming, Vol II of Toolkit Routines in the chapter on
DRM routines, they show an example (in C) of how to specify the name
and value part of the arglist.  They show:

	args[n].name = "label"
	args[n].value = "OK_button_label"

Now, the problem is when you look at what ARG_VAL_TYPE is it is defined to
be   (from SYS$LIBRARY:DECW$DWT_.ADA):
-- System Dependent Definitions
--
--
-- XtArgVal ought to be a union of caddr_t, char *, long, int *, and proc *
-- but casting to union types is not really supported.
--
-- So the typedef for XtArgVal should be chosen such that
--
--      sizeof (XtArgVal) >=    sizeof(caddr_t)
--                              sizeof(char *)
--                              sizeof(long)
--                              sizeof(int *)
--                              sizeof(proc *)
--
-- ArgLists rely heavily on the above typedef.
--
--***************************************************************
    subtype ARG_VAL_TYPE is INTEGER;

When he tries to assign a string to that item of the arglist, he gets a
compiler error.  Is he supposed to pass a ptr to the string? That is what
C does...  Or are the bindings in error?

Rick Beldin

2228.3QUARK::LIONELFree advice is worth every centWed Feb 07 1990 13:267
You need to assign the address of a null-terminated string to the VALUE
field of the array element.  STRNG_TYPE is a subtype of SYSTEM.ADDRESS.

The DECBURGER and HELLOWORLD Ada examples have lots of uses of this type
of construct, though FETCH_SET_VALUES isn't used directly in either one.

				Steve
2228.4ULTRA::WRAYJohn Wray, Secure Systems DevelopmentWed Feb 07 1990 13:4033
    You're better off using the convenience routines to get inside an
    ARG_ARRAY_TYPE value:
    
    declare
    	arglist : dwt.arg_array_type(0..0);
    	label : constant string:= "OK_button_label" & ascii.nul;
    begin
    	-- Put some values into the argument list
    	dwt.vms_set_arg(label'address,
    		        arglist,
    		        0,
    		        dwt.C_label);
    
    	-- Use arglist is a DWT.xxxxxx call
    
    	-- Then free any storage allocated by VMS_SET_ARG
    	for i in arglist'range loop
    	    dwt.vms_free_argnames(arglist,i);
    	    -- Free the storage allocated by VMS_SET_ARG for the
    	    -- copy it makes of the argument name
    	end loop;
    end;		
    
    There is a convenience routine called VMS_SET_DESC_ARG, which is
    supposed to stuff a string directly into an ARG_ARRAY_TYPE (so you
    don't have to declare a constant null-terminated string and get the
    address of it), but I don't see how you're supposed to free up the
    temporary storage that that will allocate (unless VMS_FREE_ARGNAMES
    is very clever, which I doubt).  Maybe the documentation fo V5.3 is
    clearer on this point?
    
    John
    
2228.5QUARK::LIONELFree advice is worth every centWed Feb 07 1990 15:134
VMS_FREE_ARGNAMES is indeed what you use to free the storage allocated
by VMS_SET_DESC_ARG.

			Steve