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

Home » Public Forums » archive » Re: Find subarray in an array?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Find subarray in an array? [message #3562] Wed, 22 February 1995 23:23
Jackel is currently offline  Jackel
Messages: 30
Registered: April 1993
Member
In article <3i018j$69q@gwdu19.gwdg.de> kettmann@linrap.dnet.gwdg.de () writes:

> I am looking for an efficient/elegant solution to find "sync words" within an
> array.
> The sync word consists of 3 consecutive bytes, for example:
> SYNC = ['14'XB, '6f'XB, '2e'XB]
> and I need to find the position of the first element of SYNC within an array
> (it is not granted that there is any SYNC, it there could be more than one
> SYNC).


If your data is a byte stream, then you might try converting it to a string,
and using the STRPOS command. For example

sync= [1B, 2B, 3B]
syncstring= STRING(sync) ;convert to a 3 character string

data= [0B, 1B, 1B, 2B, 3B, 0B] ;create a dummy data stream containing "sync"
datastring= STRING(data) ;convert it to a string

syncpos= STRPOS(datastring,syncstring,0)

will find the first (if any) occurance of "sync" within "data". However, I
haven't tested to see if it is any faster than 3 successive WHERE's.

Brian Jackel
University of Western Ontario
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: RPC problems solved (Was: Re: IDL via RPC (Solaris 2.3))
Next Topic: device fonts

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

Current Time: Fri Oct 10 09:07:16 PDT 2025

Total time taken to generate the page: 1.36133 seconds