[mod.computers.vax] A Gotcha in the CLI$ Interface

forrest@cgl.ucsf.edu@blia.UUCP (02/13/87)

Here's something that I consider a bug that caused me to
spend a fair amount of time to chase down.

The problem is that if you call CLI$GET_VALUE to retrieve
the value of a qualifier from the command line, you can't call
CLI$GET_VALUE again to get the value of the same qualifier.
Instead, the second call returns the status CLI$_ABSENT.
In other words, once you get a value of a qualifier, you can't
get it again. This would be acceptable if it weren't for the
fact that CLI$PRESENT returns "true" if you call it before
the second call to CLI$GET_VALUE.

Now, it could be said that a "true" value from CLI$PRESENT
means that the qualifier was given on the command line,
and not that you can actually retrieve the value. This
I find to be a strange way of doing things. What's the use
of knowing that a qualifier that takes a value was given
on a command line if you can't retrieve the value?
Furthermore, the current behavior allows the status
CLI$_ABSENT to be returned even though CLI$PRESENT returned
true. In other words, something can be both PRESENT and
ABSENT at the same time. My high school vice-principal never
believed this; why should I?

On the other hand, this behavior makes sense if the qualifier
is of type "LIST", in which case you'd want to call CLI$GET_VALUE
over and over until you exhaust the list. This works properly
now. My complaint is that, unless the qualifier is of type "LIST",
you should be able to call CLI$GET_VALUE to retrieve the value
of a qualifier as many times as you want.

The following is a sample program and a sample cld file that
illustrates the behavior I've described. I've used FORTRAN only
because it's easier to deal with character descriptors than in C,
which is what I normally use.

	INTEGER STATUS,LEN,CLI$PRESENT,CLI$GET_VALUE
	CHARACTER*10 PARAM
C
	IF (CLI$PRESENT('TEST')) THEN
		TYPE *, '1ST TEST: TEST IS PRESENT'
		STATUS = CLI$GET_VALUE('TEST',PARAM,LEN)
		IF (.NOT. STATUS) THEN
			TYPE *, 'COULD NOT GET VALUE'
			CALL LIB$SIGNAL(%VAL(STATUS))
		ELSE
			TYPE *, 'VALUE IS ',PARAM
		ENDIF
	ENDIF
C
	IF (CLI$PRESENT('TEST')) THEN
		TYPE *, '2ND TEST: TEST IS PRESENT'
		STATUS = CLI$GET_VALUE('TEST',PARAM,LEN)
		IF (.NOT. STATUS) THEN
			TYPE *, 'COULD NOT GET VALUE'
			CALL LIB$SIGNAL(%VAL(STATUS))
		ELSE
			TYPE *, 'VALUE IS ',PARAM
		ENDIF
	ENDIF
	CALL EXIT
	END

---------------------------------------------------
DEFINE VERB CLD
IMAGE "TMP:CLD.EXE"
QUALIFIER TEST,VALUE(REQUIRED)