affecting either all objects or wildcard objects

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
Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

affecting either all objects or wildcard objects

Post by Da_Elf » Thu Jul 24, 2014 5:09 pm

Just wondering is i could so something like
on mouseUp
set the text of all fields to empty
end mouseUp

or field "price"*

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: affecting either all objects or wildcard objects

Post by dunbarx » Thu Jul 24, 2014 5:18 pm

Hi.

Of course. Do you mean all fields on one card or on other cards as well?

Anyway, there is not "all fields" capability in LC. You have to loop through the fields one by one and, if you want to, check a property as you go, and empty the field in that process:

Code: Select all

repeat with y = 1 to the number of fields
  if the short name of fld y is "price" then put "" into fld y
end repeat
As payment, please rewrite this to cover all cards in a stack. And then write back and tell me why "the number of fields" in the first line is such a nice thing.

Craig Newman

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

Re: affecting either all objects or wildcard objects

Post by Klaus » Thu Jul 24, 2014 5:19 pm

No, you can't, you need to use a repeat loop:

Code: Select all

...
lock screen
repeat with i = 1 to the num of fields
  put empty into fld i
end repeat
unlock screen
...

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: affecting either all objects or wildcard objects

Post by Da_Elf » Thu Jul 24, 2014 5:31 pm

would that work dunbarx?

Code: Select all

repeat with c = 1 to the num of cards
  repeat with i = 1 to the num of fields
    put empty into fld i of card c
  end repeat
end repeat
your advice worked though. thanks guys

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

Re: affecting either all objects or wildcard objects

Post by Klaus » Thu Jul 24, 2014 5:35 pm

Code: Select all

repeat with c = 1 to the num of cards
  repeat with i = 1 to the num of fields OF CD c
    put empty into fld i of card c
  end repeat
end repeat

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10333
Joined: Wed May 06, 2009 2:28 pm

Re: affecting either all objects or wildcard objects

Post by dunbarx » Thu Jul 24, 2014 5:46 pm

What Klaus said again.

Do you see? Read carefully the second line. You make no reference to the card the fields are on. This would work in the current card, because LC defaults much behavior to that state of affairs. But if you are talking about another card, the reference breaks.

This is possible if you consider the following:

Code: Select all

lock screen
repeat with c = 1 to the number of cards
  go cd c
  repeat with i = 1 to the num of fields
    put empty into fld i
  end repeat
end repeat
The first way is better, by the way, since it is faster. You do not need to navigate to a distant card to do stuff on it. But you do need to know the difference, and the possibility.

Craig

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: affecting either all objects or wildcard objects

Post by Da_Elf » Fri Jul 25, 2014 6:10 am

doh!. forgot the card reference.
i didnt need to span to other cards. it was an "on openCard" type thing that checked if a global variable asked for the fields of the card to be cleared when entering it or if they should be filled

Post Reply