how to find offset of =

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
renevanp
Posts: 10
Joined: Mon Jan 12, 2009 8:31 pm

how to find offset of =

Post by renevanp » Sun Dec 12, 2010 1:51 pm

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?
Last edited by renevanp on Sun Dec 12, 2010 2:19 pm, edited 1 time in total.

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: how to find offset of =

Post by bangkok » Sun Dec 12, 2010 2:09 pm

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 )

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: how to find offset of =

Post by bn » Sun Dec 12, 2010 2:11 pm

Hi Rene,

you forgot the ampersand (&)

Code: Select all

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

renevanp
Posts: 10
Joined: Mon Jan 12, 2009 8:31 pm

Re: how to find offset of =

Post by renevanp » Sun Dec 12, 2010 2:25 pm

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

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4172
Joined: Sun Jan 07, 2007 9:12 pm

Re: how to find offset of =

Post by bn » Sun Dec 12, 2010 2:51 pm

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

renevanp
Posts: 10
Joined: Mon Jan 12, 2009 8:31 pm

Re: how to find offset of =

Post by renevanp » Sun Dec 12, 2010 2:54 pm

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

Post Reply