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

Home » Public Forums » archive » Re: quick testing of string variables
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: quick testing of string variables [message #6123 is a reply to message #6112] Tue, 23 April 1996 00:00 Go to previous message
rivers is currently offline  rivers
Messages: 228
Registered: March 1991
Senior Member
In article <moninger-2304960900010001@zirkle.fsl.noaa.gov>, moninger@fsl.noaa.gov (Bill Moninger) writes:
> I have an array called station_name, dimensioned (6,n). Each item is a
> string 6 characters long. I would like to quickly test station_name
> against a particular string variable, find_this_station, another string of
> dimension 6.
>
> Is there any way to do this without using loops?
>
> If I have to use loops, does anyone have a tip on the fastest way to do so?
>
> Is there are better way to configure the array station_name to make such
> tests (against a particular station name) faster?

Here is how to do it:

IDL> a = ['s1', 's2', 's3', 's4', 's5', 's6']
IDL> t = where(a eq 's4')
IDL> print, t
3

The where() function finds the index number of the string in the array which
matches your test string. It returns -1 if there is no match.

____________________________________________________________
Mark Rivers (312) 702-2279 (office)
CARS (312) 702-9951 (secretary)
Univ. of Chicago (312) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars3.uchicago.edu (Internet)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: IDL CGM driver
Next Topic: High color on window95

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

Current Time: Fri Oct 10 21:11:24 PDT 2025

Total time taken to generate the page: 1.12306 seconds