Page 1 of 1

Generic Stack Resize scrip throwing (odd?) error

Posted: Sat Nov 09, 2013 11:24 am
by Traxgeek
Hi,

Having played around with MobGUI for a bit and although I've looked at various resize scripts both here and on other forums I've been playing around with creating a generic Stack resize script that handles much of what I've seen plus text scaling within buttons and fields etc...

So, I figured my code block may look something like
-1- cycle through each card...
-2- cycle through each control
-3- modify each control's X, Y etc. etc.
-4- note if there was any text (like a button name, field content etc) and then modify the font size
-5- do any other adjustments according to control 'type'
next control
next card

Seems pretty simple - at least the thought process seems pretty straight forward...

So, first:
Just to create the 'cycle though' / repeat loops and 'see' a list of controls :
(some test code)

local nCS, nCrd, nCtrls, nCtrlID, sCtrl, sCtrlType --create the necessary variables...
put the number of cards of this stack into nCS
repeat with nCrd = 1 to nCS --cycle through each card
put the number of controls of card nCrd into nCtrls
if nCtrls > 0 then
repeat with nCtrl = 1 to nCtrls --cycle through each control on the current card
put the name of control nCtrl into sCtrl --This is MY Control name
put word 1 of sCtrl into sCtrlTyp --This is the Control Type (Button, filed, image, group...)
put word 3 of sCtrl into nCtrlID --This is LC's control name (unique Control ID)
end repeat
end if
end repeat

This code runs as expected until control # 21 on any card - when it fails at the 'put the name of control nCtrl... (the first line of the repeat through each control structure...) !

Upon failure I receive the message:
Stack... : execution error at line... (Chunk: no such object) near "21", char 26

So, typing :
put the long id of control 21 of card nCrd -- change nCrd to any valid card number you like - where there are more than 20 controls on it)

produces a result like :
field id 2086543 of group id 2086537 of group id 1112377 of group id 1112375 of group id 1112368 of card id 1112149 of stack "/Users/Trax/Documents/My Projects/.....

So... ? ? ?

What the heck's going on here ?

Any ideas where Im going wrong please ?

Much appreciated...

EDIT 1: In desperation, I tried this in LC V5.5.4 and came up the same result
Currently I'm using (by default) LC V6.1.2
So, it's my code/logic... but where / why... arghhhh ?!

Re: Generic Stack Resize scrip throwing (odd?) error

Posted: Sat Nov 09, 2013 12:56 pm
by Traxgeek
Eeeegit !

I've seen the light !!! Yahay !

Needed to reference the card on which the control resides to access the control...

put the name of control nCtrl into sCtrl

...becomes...

put the name of control nCtrl of card nCrd into sCtrl

D'Oh ! Don't want to think about the number of hours I wasted on this one :oops: