Basket help

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

AzTheBest
Posts: 25
Joined: Wed May 04, 2016 2:19 pm

Re: Basket help

Post by AzTheBest » Sat Jun 18, 2016 6:06 pm

a button has this code

Code: Select all

additem "Chicken Steak","",5 
this code is in stack 8 and goes in to table called "table" in stack 8

i just want to know how i can move the button different stack e.g stack 1 and it input the data into stack 8 :|

sritcp
Posts: 431
Joined: Tue Jun 05, 2012 5:38 pm
Location: Alexandria, Virginia

Re: Basket help

Post by sritcp » Sat Jun 18, 2016 6:19 pm

dunbarx wrote:... I am amazed at how attractive they are to new users. So many start right in with them embedded in their projects, oftentimes the central control...
Craig
It just shows the need for a feature-rich table widget that is not as complex as the Datagrid, but more usable than the primitive table object that comes with LC.
It is a major deficiency that needs to be corrected.

Regards,
Sri

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Basket help

Post by Klaus » Sat Jun 18, 2016 6:24 pm

AzTheBest wrote:a button has this code

Code: Select all

additem "Chicken Steak","",5 
this code is in stack 8 and goes in to table called "table" in stack 8
i just want to know how i can move the button different stack e.g stack 1 and it input the data into stack 8 :|
Sorry, still have no idea what exactly you are trying to do!?
Please also post the script of your "additem" handler!

Are you really naming your stacks with numbers?

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Basket help

Post by sturgis » Sat Jun 18, 2016 6:25 pm

You can use "dispatch" or "send" for this. Look earlier in this thread for an example using dispatch.

dispatch "addItem" to <where do you want it go go? " with the info you want to go along goes here.

For example if you had a command that adds 2 numbers on a different stack, in a button on a card you could do this..

dispatch "myAddCommand" to button "addB" of card "mySpecialCard" of stack "mySpecialStack" with 2,23

Which would cause the myAddCommand in the button to fire and add numbers 2 and 23

AzTheBest
Posts: 25
Joined: Wed May 04, 2016 2:19 pm

Re: Basket help

Post by AzTheBest » Sat Jun 18, 2016 6:39 pm

sturgis wrote:You can use "dispatch" or "send" for this. Look earlier in this thread for an example using dispatch.

dispatch "addItem" to <where do you want it go go? " with the info you want to go along goes here.

For example if you had a command that adds 2 numbers on a different stack, in a button on a card you could do this..

dispatch "myAddCommand" to button "addB" of card "mySpecialCard" of stack "mySpecialStack" with 2,23

Which would cause the myAddCommand in the button to fire and add numbers 2 and 23

Code: Select all

dispatch "additem" "Chicken Steak","",5   to "table" of card "8" of stack "Restraunt Template" 
i keep getting error as i did find this online to? but im guessing putting the code in wrong? :oops:

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Basket help

Post by Klaus » Sat Jun 18, 2016 6:52 pm

We might STILL take a look at your "additem" handler, as I already wrote! 8)

BUT:

Code: Select all

dispatch "additem" "Chicken Steak","",5   to "table" of card "8" of stack "Restraunt Template"
1. You need to supply the TYPE of object that you are addressing:
... to FIELD "table"...
or:
... to GROUP "table"...

2. NEVER EVER name your objects/cards/stacks as NUMBERS! NEVER! :D
That is asking for trouble, since the engine does not differ between the STRING 8 and the NUMBER 8,
so it looks for a card NUMBER 8 and will throw an error if there are less cards in the target stack!

AzTheBest
Posts: 25
Joined: Wed May 04, 2016 2:19 pm

Re: Basket help

Post by AzTheBest » Sat Jun 18, 2016 6:59 pm

okay i edited my code thanks but still no luck haha

to anwser ur question it is a basic table field :|

AzTheBest
Posts: 25
Joined: Wed May 04, 2016 2:19 pm

Re: Basket help

Post by AzTheBest » Sat Jun 18, 2016 7:07 pm

Klaus wrote:We might STILL take a look at your "additem" handler, as I already wrote! 8)

BUT:

Code: Select all

dispatch "additem" "Chicken Steak","",5   to "table" of card "8" of stack "Restraunt Template"
1. You need to supply the TYPE of object that you are addressing:
... to FIELD "table"...
or:
... to GROUP "table"...

2. NEVER EVER name your objects/cards/stacks as NUMBERS! NEVER! :D
That is asking for trouble, since the engine does not differ between the STRING 8 and the NUMBER 8,
so it looks for a card NUMBER 8 and will throw an error if there are less cards in the target stack!
i didnt name the card as a number but they all called "Restraunt Template" then next to it has (1), (2) etc.
what im trying is to move information from the 1st stack by clicking button to stack 8 into my basic table field

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Basket help

Post by Klaus » Sat Jun 18, 2016 7:08 pm

I hate to repeat myself, but:
We might STILL take a look at your "additem" handler, as I already wrote!
8)

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Basket help

Post by Klaus » Sat Jun 18, 2016 7:09 pm

AzTheBest wrote:i didnt name the card as a number but they all called "Restraunt Template" then next to it has (1), (2) etc.
So it is really card NUMBER 8 of that stack?
Then you do not need to use QUOTES! :D

AzTheBest
Posts: 25
Joined: Wed May 04, 2016 2:19 pm

Re: Basket help

Post by AzTheBest » Sat Jun 18, 2016 7:13 pm

Code: Select all

dispatch "additem" "Chicken Steak","",5   to "table" of card "8" of stack "Restraunt Template"
but where do i get rid of the quotes sorry for a pain :oops:

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Basket help

Post by Klaus » Sat Jun 18, 2016 7:16 pm

... of cd 8 of stack "xyz"

But that is surely not the problem, so we still need to look at your "additem" handler.
No idea if i already mentioned this. 8)

AzTheBest
Posts: 25
Joined: Wed May 04, 2016 2:19 pm

Re: Basket help

Post by AzTheBest » Sat Jun 18, 2016 7:31 pm

would u recommend any other way :?

Klaus
Posts: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Basket help

Post by Klaus » Sat Jun 18, 2016 7:38 pm

I would recommend to use the correct syntax as Sturgis suggested:
...
dispatch "additem" to field "table" of card 8 of stack "Restraunt Template" WITH "Chicken Steak","",5
...
And if that does not work I will not ask a 6th time for the script of your handler "additem" 8)

AzTheBest
Posts: 25
Joined: Wed May 04, 2016 2:19 pm

Re: Basket help

Post by AzTheBest » Sat Jun 18, 2016 7:46 pm

Klaus wrote:I would recommend to use the correct syntax as Sturgis suggested:
...
dispatch "additem" to field "table" of card 8 of stack "Restraunt Template" WITH "Chicken Steak","",5
...
And if that does not work I will not ask a 6th time for the script of your handler "additem" 8)
okay i did that and it worked but then script of the handler "add item" showed up

Code: Select all

command addItem pMenuItem,pDrinkItem,pCost
   lock screen
   if field "table" is not empty then put cr after field "table"
   put pMenuItem & tab & pDrinkItem & tab & "£" &  pCost & tab &  1  & tab & "£" & pCost after field "table"
   if (the number of lines in field "table" mod 2) is 0 and field "table" is not empty then
      
   else
set the backgroundcolor of line -1 of field "table" to empty
   end if
   unlock screen
end addItem
and sorry was confused what u were asking but here it is :)

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”