Page 1 of 1

how to find offset of =

Posted: Sun Dec 12, 2010 1:51 pm
by renevanp
I want to determine if a variable contains the = sign

I'm ussing:
$inhoudregel contains: Instellingen_MCMbestandenpath=T:\MCMbestanden

repeat for each line $inhoudregel in $inhoud
switch
--testen of het een section regel is
case offset("[",$inhoudregel ) is 1
--sectieregel gewoon overnemen
put $inhoudregel & return after $newInhoud
break
case offset("#",$inhoudregel ) is 1
--sectieregel gewoon overnemen
put $inhoudregel & return after $newInhoud
break
case offset(";",$inhoudregel ) is 1
--sectieregel gewoon overnemen
put $inhoudregel & return after $newInhoud
break
case offset("=",$inhoudregel ) is greather than 1
--sleutels eventueel aanpassen
put offset("=",$inhoudregel ) into $Isteken
put char 1 to ($Isteken - 1) of $inhoudregel into $propkey
if exists(myCustomProps[$propkey]) then
--waarden aanpassen
put $propkey & "=" & myCustomProps[$propkey] & return after $newInhoud
else
--oude waarden weer terugschrijven
put $inhoudregel & return after $newInhoud
end if
break
default
--answer "offset = " offset("=",$inhoudregel )
--sleutels eventueel aanpassen
put offset("=",$inhoudregel ) into $Isteken
put char 1 to ($Isteken - 1) of $inhoudregel into $propkey
if myCustomkeys contains $propkey then
--waarden aanpassen
put $propkey & "=" & myCustomProps[$propkey] & return after $newInhoud
else
--oude waarden weer terugschrijven

end if
end switch

end repeat

This doesn't work: case offset("=",$inhoudregel ) is greather than 1
in the default part put offset("=",$inhoudregel ) into $Isteken does work

Do I need an escape character to escape the = sign?

Re: how to find offset of =

Posted: Sun Dec 12, 2010 2:09 pm
by bangkok
renevanp wrote: put "Instellingen_MCMbestandenpath=T:\MCMbestanden" into $inhoudregel2
answer "offset = " offset("=",$inhoudregel2 )
You have to use the " & " character.

Code: Select all

   put "Instellingen_MCMbestandenpath=T:\MCMbestanden" into $inhoudregel2
   answer "offset = " & offset("=",$inhoudregel2 )

Re: how to find offset of =

Posted: Sun Dec 12, 2010 2:11 pm
by bn
Hi Rene,

you forgot the ampersand (&)

Code: Select all

 put "Instellingen_MCMbestandenpath=T:\MCMbestanden" into $inhoudregel2
 answer "offset = " & offset("=",$inhoudregel2 )
this works
regards
Bernd

Re: how to find offset of =

Posted: Sun Dec 12, 2010 2:25 pm
by renevanp
Thanks Bernd that does indeed work with answer

But when you answered I was just editing my post, I still have a problem with the following line
case offset("=",$inhoudregel ) is greather than 1 which doesn't seem to work

Re: how to find offset of =

Posted: Sun Dec 12, 2010 2:51 pm
by bn
Rene,

Bangkok was first... :)

you can use case only inside a switch statement.

You could say this:

Code: Select all

on mouseUp
   put "Instellingen_MCMbestandenpath=T:\MCMbestanden" into $inhoudregel2
   put offset("=",$inhoudregel2 ) into tWhere
   if tWhere > 0 then
      answer "offset = " & tWhere
   end if
end mouseUp
if the offset function returns 0 it did not find anything
regards
Bernd

Re: how to find offset of =

Posted: Sun Dec 12, 2010 2:54 pm
by renevanp
Ok I figured it out myself

greather than 1 is not working because it is not good english
greater than 1 is not working
> 1 does work

thanks to all that replied