Using datas from one card to another from the same stack

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
Youks
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 135
Joined: Mon Sep 05, 2011 6:08 pm

Using datas from one card to another from the same stack

Post by Youks » Tue Sep 20, 2011 10:17 am

Hi All, this is my first post into the forum and i want to thank you all in advance for your help.
I went through all the the forum and the manuals but it is not clear yet to me, so i hope that somebody will enlight me for this little issue.

I have one stack with 6 cards.
On Card 1 i use a database (sqlite with 5000 rows of 15 columns) which i put on a string tData. i am able to chunk this and get the items which i display on some texfields of Card1.

--On mouseup
chunk tData
display some of the infos on this Card
Press a field to access Card2 and display remaining items on textfields
--end mouseup

Now obviously when i am in Card 2, my problem is that i cannot display the remaining items.

Sorry it might be silly but i still don't get how to make it run!!!
I reviewed the "Send" command, and the Global declare but still.......... :oops:

Regards to All.

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

Re: Using datas from one card to another from the same stack

Post by Klaus » Tue Sep 20, 2011 12:14 pm

Hi Youks,
I am not sure what exactly your probkem is, but you can access every object on every card
in every stack by adding the appropriate "descriptor" to your scripts.

Like this:
...
## CD = abbreviation for CARD!
put fld "your field here" of cd 1 into fld "another nice field" of cd 4
...
## Or even from one stack to another
put fld "your field here" of cd 1 of stack "stack1" into fld "another nice field" of cd 4 of stack "stack2"
...
No need to "send" of use globals, if that is what you mean?


Best

Klaus

Youks
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 135
Joined: Mon Sep 05, 2011 6:08 pm

Re: Using datas from one card to another from the same stack

Post by Youks » Tue Sep 20, 2011 1:25 pm

Hi Klaus, thx for your fast reply but this is what i want to do:

on mouseUp -------- Button depicted in Card 1
local gConID
local tData, tData,tSQL, li
put "SELECT * FROM DGTABLE" into tSQL
put revDataFromQuery(tab,cr, gConID, tSQL) into tData

set the itemdelimiter to tab
set the columndelimiter to comma

if item 1 of tData = "revdberr" then      
answer error "There was a problem querying the database:" & cr & tData   
else    
put random(4000) into li ---- for testing i am selecting 1 row of data among 4000 fields "ShpName"&"UnID" are in the present card
put item 3 of line li of tData into field "ShpName"
put item 2 of line li of tData into field "UnID"
end if

end if
end mouseUp

So from this Card i want to access Card 3 through a button and continue to display the other "items" into fields of Card 3.

Sorry Klaus i tried to explain my issue hoping that you'll guide me through the best and shortest way to achieve that.
(i can still hide the fields in card 1 and use your solution but i am sure there is a better approach)
Regards.

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

Re: Using datas from one card to another from the same stack

Post by Klaus » Tue Sep 20, 2011 1:47 pm

Hi Youks,

OK, your script is clear, but I still don't know WAHT you want to continue to display on card 3?
Coulp you write some "pseudo-code", so I know what you need?


Best

Klaus

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

Re: Using datas from one card to another from the same stack

Post by Klaus » Tue Sep 20, 2011 1:52 pm

Hi Youks,

I think I get it :D

See my first posting, this should be applicable here!

You mean something like this:
...
if item 1 of tData = "revdberr" then
answer error "There was a problem querying the database:" & cr & tData
else
put random(4000) into li ---- for testing i am selecting 1 row of data among 4000 fields "ShpName"&"UnID" are in the present card
put item 3 of line li of tData into field "ShpName"
put item 2 of line li of tData into field "UnID"

## !!
put item 1 of line li of tData into field "WHATEVER 1" of cd 3
put item 4 of line li of tData into field "WHATEVER 4" of cd 3
## etc. for all ITEMS you want to show in fields on card 3
end if
...

Now you can simply use "go cd 3" in your button and all fields on that card are already nicely filled with your data.

Is that what you had in mind?


Best

Klaus

Youks
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 135
Joined: Mon Sep 05, 2011 6:08 pm

Re: Using datas from one card to another from the same stack

Post by Youks » Tue Sep 20, 2011 2:38 pm

Dear Klaus,

Thank You so much, i was sure it was "SO!" easy......... i fact i was trying that but instead of "cd 3" i was using "card 3"??? :oops:
I am currently working on an iPhone app and i am sure that i will be back soon.....for more serious issues!!!

Regards,

Youks
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 135
Joined: Mon Sep 05, 2011 6:08 pm

Re: Using datas from one card to another from the same stack

Post by Youks » Tue Sep 20, 2011 2:45 pm

OOOps, it wasn't a problem of card 3 or cd3( nonsense ?!?!) but fields!! I just realized this now! Thx Klaus!

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

Re: Using datas from one card to another from the same stack

Post by Klaus » Tue Sep 20, 2011 3:19 pm

Hi Youks,

glad you got it working!

I use a lot of abbreviations, saves a lot of typing :D
sb = scrollbar
fld = field
btn = button
grc = graphic
img = image
cd = card !!!

You should also check these stacks, great learning resource:
http://www.runrev.com/developers/lesson ... nferences/


Best

Klaus

Youks
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 135
Joined: Mon Sep 05, 2011 6:08 pm

Re: Using datas from one card to another from the same stack

Post by Youks » Tue Sep 20, 2011 7:42 pm

Very Helpful indeed!!!
Thx

Post Reply