Optimizing syntax

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
atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Optimizing syntax

Post by atout66 » Tue Apr 15, 2014 4:29 pm

Hi to all,

Any idea how could I optimize this line of "bad" code :

Code: Select all

set the unicodeText of fld "lesSommaires" of card laCardDeRef of stack laStackDeRef to uniEncode (lesSommaires, "UTF8") 
All the variables are OK, but LC can't compile such line it seems...
The problem occures because the script runs from a main card from where I go to another card to create fields, name them, size them and so on, and then I ask throught the script to do things in this main card; that's why I write " of card laCardDeRef of stack laStackDeRef"

Kind regards, Jean-Paul.
Discovering LiveCode Community 6.5.2.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Optimizing syntax

Post by Klaus » Tue Apr 15, 2014 4:34 pm

Bonjour Jean-Paul,
atout66 wrote:...it seems...
come on, does LC compile or not? 8)
If not, what error do you get?

Syntax looks definitively correct!


Best

Klaus

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Optimizing syntax

Post by atout66 » Tue Apr 15, 2014 4:44 pm

Hi Klaus,
Yes, LC compile, it's during runtime it doen't find the stack...
Any way this script cause me troubbles and crash LC :mrgreen:
I'm going to step by step debug it (534 lines !)

Kind regards, Jean-Paul.
Discovering LiveCode Community 6.5.2.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Optimizing syntax

Post by Klaus » Tue Apr 15, 2014 4:47 pm

And you are sure "laStackDeRef" contains a valid stack name and that stack is open?

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Optimizing syntax

Post by atout66 » Tue Apr 15, 2014 5:47 pm

Well, I think so :wink:
I even replace them by global vars like this:

Code: Select all

put the name of this stack into gLaStackDeRef
put the name of this card into gLaCardDeRef
Both are correct.
I think I move to much from one card to another inside this script.

Anyway, the syntax is correct.
I'm going to change the way I arrange things :wink:

Thanks for your time,
Kind regards, Jean-Paul.
Discovering LiveCode Community 6.5.2.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Optimizing syntax

Post by Klaus » Tue Apr 15, 2014 6:31 pm

AHA! Did you ever check the CONTENT of your variables? :D

Problem is "the name of this stack" and "the name of this cd", which are actually:
the name of this stack -> STACK "name of stack"
the name of this cd -> CARD "name of card"
Surely not what you (and the engine) have exspected 8)

Use "the short name of" instead and the rest of your script will work:

Code: Select all

put the short name of this stack into gLaStackDeRef
put the short name of this card into gLaCardDeRef
Best

Klaus

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Optimizing syntax

Post by atout66 » Tue Apr 15, 2014 7:01 pm

Ah, you've got it Klaus !
It was written as a custom propertie if I understand you right. That's why in the debugger I could see "stack xxx" instead of the name of the stack only :!:

Thanks a lot and
Kind regards, Jean-Paul.
Discovering LiveCode Community 6.5.2.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Optimizing syntax

Post by Klaus » Tue Apr 15, 2014 7:06 pm

atout66 wrote:It was written as a custom propertie if I understand you right.
No, the compiler does not check for VALID variables content, that's why he did not complain :D

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: Optimizing syntax

Post by atout66 » Wed Apr 16, 2014 8:38 am

Are you trying to say that the engine is more intelligent than me ? :D (humour)
Discovering LiveCode Community 6.5.2.

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Optimizing syntax

Post by Klaus » Wed Apr 16, 2014 11:43 am

Well, erm, may I call my lawyer? :D

Post Reply