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

Home » Public Forums » archive » Re: storing in array
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: storing in array [message #60230 is a reply to message #60223] Mon, 12 May 2008 07:09 Go to previous messageGo to previous message
Spon is currently offline  Spon
Messages: 178
Registered: September 2007
Senior Member
On May 11, 12:48 am, kishore1...@gmail.com wrote:
> vfm_feature_flags,36282
Also, be careful: the above number is converted to a longword integer
by IDL. This might cause headaches later on if you're expecting a 16-
bit input. You could use:
vfm_feature_flags,36282u
to ensure the number is defined as a 16-bit unsigned integer.
I would protect my code like this:
---

function vfm_feature_flags, input

; Check input
if input gt 65535L or input lt -32767L then $
message, 'Input not a 16-bit flag.'

; Convert input to unsigned integer
val = uint(input)

---
You've already written a loop to convert your flag to sub-flags, so
this may be superfluous, but I've had a dig around the format codes
and come up with this:
---

; Convert to left-zero-padded 16-char string
bval = string(val, format = '(B016)')

; And then you can extract substrings to get
; the sub-flag values using ReadS:
ftflag = strmid(bval, 0, 3) ; Position 0, length 3
feature_type = 0u
reads, ftflag, format = '(B)', feature_type

ftqflag = strmid(bval, 3, 2) ; Position 3, length 2
feature_type_qa = 0u
reads, ftqflag, format = '(B)', feature_type_qa
; and so on.

---
I have to say, the fact that ReadS is a procedure and not a function,
plus the fact that you can't pass type codes to it for your output
does seem a bit counter-intuitive to me. Your FOR loop will in theory
be slower,but probably not noticably; and at least it's pretty easy to
follow compared to messing about with format codes. But it can be done
without the loop.

Regards,
Chris
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to HIDE a WIDGET_BUTTON and dont hide the widget hierarchy ?
Next Topic: Re: not yet another workbench workspace question!?!

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

Current Time: Fri Oct 10 14:34:34 PDT 2025

Total time taken to generate the page: 0.16260 seconds