[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
System Variables: defining and using
- Subject: System Variables: defining and using
- From: Ray Muzic <rfm2(at)po.cwru.edu>
- Date: Tue, 28 Apr 1998 10:02:42 -0400
- Newsgroups: comp.lang.idl-pvwave
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:10852
I wrote a function is_little_endian to determine if a system uses little
endian data representation. (see below) It doesn't compile in IDL4 or
IDL5. An error is generated on the return statement with the message
that system variable !little_endian does not exist. Apparently IDL
requires the system variable to be defined at compile time.
The idea was to, on the first call to this function, determine the
endian of the system and store info in a system variable. On subsequent
calls the function should note that the
system variable exists and use the stored result.
Is there a way to do this using system variables? I'd prefer to not use
I relalize the endian determination is a cheap calculation so there is
question as to whether or not saving the result in a system variable is
really worthwhile. Nevertheless, I'm interested in the solution in
regards to saving results in system variables in other applications.
; is_little_endian() returns
; 1b (true) if system uses little endian data representation
; 0b (false) otherwise.
; Side effects: Creates and sets the value of a sustem variable
; if it does not already exist.
if i ne 1 then defsysv,'!little_endian', (byte(1, 0, 1))(0)
; grab first byte of a 2 byte integer representation of 1 (1st arg. to