How do I erase graphics?
Moderators: FourthWorld, heatherlaine, Klaus, robinmiller
How do I erase graphics?
Hello folks,
I am excited about Revolution Studio, and now I imported an old HyperCard stack for the first time.
Almost everything works fine (and I can fix the remaining problems), but after trying some time with different functions and searching the help engine, I gave up with this problem:
I want to erase all graphic objects (lines etc.) on a specific card automatically. In the Hypercard version, I used this handler:
on clearscreen
choose "select tool"
doMenu "Select all"
doMenu "Clear Picture"
end clearscreen
This doesn't work, even when I translate it to the syntax of RR.
There MUST be a solution. Does anybody know it?
Thanks a lot,
Arndt
I am excited about Revolution Studio, and now I imported an old HyperCard stack for the first time.
Almost everything works fine (and I can fix the remaining problems), but after trying some time with different functions and searching the help engine, I gave up with this problem:
I want to erase all graphic objects (lines etc.) on a specific card automatically. In the Hypercard version, I used this handler:
on clearscreen
choose "select tool"
doMenu "Select all"
doMenu "Clear Picture"
end clearscreen
This doesn't work, even when I translate it to the syntax of RR.
There MUST be a solution. Does anybody know it?
Thanks a lot,
Arndt
In the stack script:
Anywhere:
Code: Select all
getProp objects
repeat with x = 1 to number of controls of the target
put the long name of control x of the target & return after myList
end repeat
sort myList
return myList
end objects
Code: Select all
on deleteAllObjOfCd cardNum
put the objects of card cardNum into cardObjects
repeat for each line curObj in cardObjects
delete curObj
end repeat
end deleteAllObjOfCd
???
Dear xApple....
... sorry, but I am probably too stupid to understand your code and how to use it.
Do you have some explanations for me or even a simpler (more "intuitive") way for doing it?
Sorry for being a dummie,
Arndt
... sorry, but I am probably too stupid to understand your code and how to use it.
Do you have some explanations for me or even a simpler (more "intuitive") way for doing it?
Sorry for being a dummie,
Arndt
-
- VIP Livecode Opensource Backer
- Posts: 1236
- Joined: Sat Apr 08, 2006 1:10 pm
- Location: Zurich
- Contact:
Here's a maybe simpler to understand example (with bonus comments):
When I started beginning using loops to delete objects, I always tried to use "repeat for the number of graphics times". But that wouldn't work, and I had to make complicated workarounds. That is because it would delete a graphic, and that'd change the number of graphics. So after deleting half of them, it would try to delete non-existent graphics, and generate an error. The above example should work fine though, because it starts deleting at the top, and automatically subtracts one from the variable "currentCount".
Code: Select all
on mouseUp
--will run if you click on button containing the script
lock screen
--makes it run faster, remove for visual proofing
put the number of graphics into theGraphsCount
repeat with currentGraphic = theGraphsCount down to 1
--will loop as many times as there are graphics
if there is a graphic currentGraphic then
--check if there really is a graphic currentGraphic (optional)
delete graphic currentGraphic
--removes the graphic
end if
end repeat
end mouseUp
--the 3 lines above end all the opened control structures
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Re: How do I erase graphics?
Hello,
I'm wondering if there's an easy way to select (and ultimately delete) multiple buttons on a card by name? I'm not looking to delete *all* of the buttons on my card, just the ones that begin with "myButtonNamePrefix". I'm relatively new to LiveCode, and in other scripting languages, I'd just do something like this (using a "*" wildcard):
select "myButtonNamePrefix*"
delete selected
or more simply:
delete "myButtonNamePrefix*"
Any help would be greatly appreciated!
Thanks in advance,
John
I'm wondering if there's an easy way to select (and ultimately delete) multiple buttons on a card by name? I'm not looking to delete *all* of the buttons on my card, just the ones that begin with "myButtonNamePrefix". I'm relatively new to LiveCode, and in other scripting languages, I'd just do something like this (using a "*" wildcard):
select "myButtonNamePrefix*"
delete selected
or more simply:
delete "myButtonNamePrefix*"
Any help would be greatly appreciated!
Thanks in advance,
John
Lodestone Animation, Inc.
Macaroni Art for iOS
Macaroni Art for iOS
-
- VIP Livecode Opensource Backer
- Posts: 3581
- Joined: Mon Jan 22, 2007 7:36 am
- Location: Berkeley, CA, US
- Contact:
Re: How do I erase graphics?
John-
you'll have to resort to a repeat loop for this:
you'll have to resort to a repeat loop for this:
Code: Select all
put the number of buttons of this card into tCount
repeat with x=tCount down to 1
if the short name of button x of this card begins with "myButtonNamePrefix" then
delete button x of this card
end if
end repeat
Re: How do I erase graphics?
Cool - looks like that's going to work!
Thanks so much, mwieder!
Thanks so much, mwieder!
Lodestone Animation, Inc.
Macaroni Art for iOS
Macaroni Art for iOS