[Gambas-user] Select Case problem

Bruce bbruen at ...2308...
Thu Mar 28 23:19:09 CET 2013


On Thu, 2013-03-28 at 11:11 +0100, Tobias Boege wrote:
> > > >
> > > 
> > > Case "BACKIMAGE[[]*]"
> > > Case "BACKIMAGE[[]*][[]*]"
> > > 
> > > Is that what you want?
> > > 
> > > Escaping '[' character in regular expression is done by using "[[]" or 
> > > "\\[". (see the documentation of LIKE).
> > > 
> > 
...
> "BACKIMAGE[*]", but also something like "BACKIMAGE[a]" which may or maybe
> not what Bruce wants...

Thanks guys,

That was the escape sequence I needed. I just couldn't see it in the
LIKE help page. I guess I'll have to put that "Read EVERY word in the
help page!" sign back up above my desk.

By way of demystification, we have over 1500 text parameter files that
represent 50 or so objects. These have evolved over several generations
of the software which now has too much "back compatibility" code in it.
So we now need to standardise all these parameter files to the current
release "shape".

The "xxxIMAGE<subtype>" parameters now looks for example like
        BACKIMAGE[N][1][0]=filename
        BACKIMAGE[E][1][0]=filename
        BACKIMAGE[E][2][0]=filename
but different parameter files might have
        BACKIMAGE[N]=filename,1  (at ver 1.0)
        BACKIMAGE[E]=filename,1,2 (at ver 3.0)
        BACKIMAGE[N][3]=filename (at ver 3.x)
        etc

(and xxxIMAGE is only one example of the problem!)

Given an arbitrary parameter file there is no way to detect which
software version it comes from.  This is further exacerbated by the fact
that individual lines in a file may accord to different versions of the
parameter syntax.  So each line in the file has to be parsed to detect
its' likely syntax version and reprocessed accordingly.

Hence,
Select Upper(Split(SourceArray[idx],"=")[0])
  Case Like "BACKIMAGE[[]*]" 'looks like a ver 1.0 to 3.0 syntax, so
    ' parse the second half of the line and pick the correct process
  Case Like "BACKIMAGE[[]*][[]*]" ' looks like a ver 3.x syntax, so
    TargetArray[idx]=ReformatBackImage_3x(SourceArray[idx])
  Case Like "BACKIMAGE[[*][[*][[*]" ' is current syntax, so
    TargetArray[idx]=SourceArray[idx]

etc etc

Thanks again
Bruce






More information about the User mailing list