Copy image to another card

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
SEAL29
Posts: 63
Joined: Fri Oct 02, 2020 3:32 pm

Copy image to another card

Post by SEAL29 » Mon Oct 12, 2020 7:23 pm

So far I have come:

Code: Select all

copy image "pic1" to card 3
But the position and rect is the same as source, how can i modify position or rect on card 3?
I tried this, but move the image on card 2 the new position

Code: Select all

copy image "pic1" to card 3
set the rect image "pic1" to "1203,174,1914,574"

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

Re: Copy image to another card

Post by Klaus » Mon Oct 12, 2020 7:38 pm

Hi SEAL29,

you are almost there :-)

Code: Select all

...
copy image "pic1" to card 3
## Now you are still on the SAME card, so you need to specify the correct ADDRESS of the image you want to modify:
set the rect OF image "pic1" OF CD 3 to "1203,174,1914,574"
## If that is what you mean.
...
Best

Klaus

SEAL29
Posts: 63
Joined: Fri Oct 02, 2020 3:32 pm

Re: Copy image to another card

Post by SEAL29 » Mon Oct 12, 2020 8:06 pm

Meanwhile I solved it, not as elegant as yours, but it works and you can even specify the location in the meantime. :D

Code: Select all

on mouseUp
   copy of image "pic1" to card 3
   go to card 3
   ask "Position:"
   put it into tNumber
   if the result = "cancel" then
      exit to top
   end if
   set the rect image "pic1" to tNumber
end mouseUp

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

Re: Copy image to another card

Post by Klaus » Mon Oct 12, 2020 9:03 pm

Hey, that's cheating! :D :D :D

But OF at the wrong position!

Code: Select all

on mouseUp
  ##  copy of image "pic1" to card 3
  copy image "pic1" to card 3
   go to card 3
   ask "Position:"
   put it into tNumber
   if the result = "cancel" then
      exit to top
   end if
  ## set the rect image "pic1" to tNumber
   set the rect OF image "pic1" to tNumber
end mouseUp
I am a bit picky in this respect, because, although it works currently, every new version of the LC engine is less forgiving with "sloppy" syntax! Believe me, I have been bitten by this fact several times in the last 21 years, and I have learned from that experience. :D

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

Re: Copy image to another card

Post by dunbarx » Tue Oct 13, 2020 1:54 am

Listen to Klaus about being careful with syntax. LC, like Hypercard before it, thought that forgiving syntax would make users feel more comfortable.

It did.

But LC has moved more into the mainstream, and this sort of looseness is becoming untenable.

Anyway, it is very useful to know that you can do anything you want to on other cards, or even cards on other stacks, WITHOUT actually navigating there. That is what was really important in what he suggested.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Copy image to another card

Post by richmond62 » Tue Oct 13, 2020 6:51 am

this sort of looseness is becoming untenable
To an extent.

There always seems to be at least 2 ways to achieve anything in LiveCode, and often many more: which is fantastic.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10048
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Copy image to another card

Post by FourthWorld » Tue Oct 13, 2020 8:22 am

richmond62 wrote:
Tue Oct 13, 2020 6:51 am
this sort of looseness is becoming untenable
To an extent.

There always seems to be at least 2 ways to achieve anything in LiveCode, and often many more: which is fantastic.
Algorithmic flexibility is very valuable. One should be able to consider many different ways to solve a given problem, as we'd expect in any good language.

Syntactic flexibility seems less useful, possibly counterproductive. Having multiple ways to express the same algorithm just adds noise to the mastery-acuisition process.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Copy image to another card

Post by richmond62 » Tue Oct 13, 2020 12:31 pm

That's exactly what my narrow-minded Chemistry teacher said about titration calculations 42 years ago.

At University the Professor (when I asked her) said that 'how one got to the result' didn't matter as long
as the result was capable of being arrived at via a different route.

(x * x) = x^2

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

Re: Copy image to another card

Post by dunbarx » Tue Oct 13, 2020 2:49 pm

Syntactic flexibility seems less useful, possibly counterproductive. Having multiple ways to express the same algorithm just adds noise to the mastery-acuisition process.
I am with you 100%. Back in the (HC) day I selected, or rather my brain selected, (not the same thing) one version of each syntactical option. For example, describing a function given the "the" way or the "()" way. Never deviated. If there had been only one, I would still not have deviated.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Copy image to another card

Post by richmond62 » Tue Oct 13, 2020 4:13 pm

I think I have been traumatised by FORTRAN IV. 8)

Post Reply