comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » System Variables: defining and using
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
System Variables: defining and using [message #11594] Tue, 28 April 1998 00:00 Go to previous message
Ray Muzic is currently offline  Ray Muzic
Messages: 5
Registered: June 1997
Junior Member
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
common blocks.

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.

function is_little_endian
; 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
!little_endian
; if it does not already exist.
;
;
defsysv,'!little_endian', exists=i
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
byte)

return,!little_endian


Ray Muzic
muzic@uhrad.com
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: 32bit signed integer problems
Next Topic: Reinventing the IDL wheel: 2D Object Graphics plots

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 22:50:08 PDT 2025

Total time taken to generate the page: 0.79929 seconds