How do I shorten this script? Use 'repeat with'?
hakan at exformedia.se
hakan at exformedia.se
Thu Nov 12 08:57:46 EST 2020
You could use two variables like tName and tPrevious
set the loc of grc "k1" to cardWidth/2,cardHeight/2
put ”k1” into tPrevious
repeat with i = 2 to 5
put ”k” & i into tName
set the topleft of grc tName to the topright of grc tPrevious
put tName into tPrevious
end repeat
Coding out of my head so reserve for mistakes!
:-Håkan
On 12 Nov 2020, 14:50 +0100, William de Smet via use-livecode <use-livecode at lists.runrev.com>, wrote:
> Hi there,
>
> Another question today.
> How do I shorten this script?
> ----
> set the loc of grc "k1" to cardWidth/2,cardHeight/2
> set the topleft of grc "k2" to (item 1 of topright of grc "k1" -1, item 2
> of topright of grc "k1")
> set the topleft of grc "k3" to (item 1 of topright of grc "k2" -1, item 2
> of topright of grc "k2")
> set the topleft of grc "k4" to (item 1 of topright of grc "k3" -1, item 2
> of topright of grc "k3")
> set the topleft of grc "k5" to (item 1 of topright of grc "k4" -1, item 2
> of topright of grc "k4")
> ----
>
> I know I should use 'repeat with' but I am stuck.
> repeat with x = 2 to 4
> put "k" & x into tName
> set the topleft of grc tName to (item 1 of topright of. grc....?.... , item
> 2 of topright of grc ...?....)
> end repeat
>
>
> Any help is appreciated!
>
>
>
> greetings,
>
> William
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list