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!
on checkData
if fld "fldQtty" is empty or hilitedbutton of grp "grpType" is 0 or hilitedbutton of grp "grpLoc" is 0 then
beep
Answer error "May nakalimutan ka ilagay pa." titled "Error: May nakalimutan ilagay"
else
put fld "fldQtty" into tQtty
if the hilite of btn "Round" then
put "Round" into tType
end if
if the hilite of btn "Slim" then
put "Slim" into tType
end if
if the hilite of btn "Clark" then
put "Clark" into tLoc
end if
if the hilite of btn "Sapangbato" then
put "Sapangbato" into tLoc
end if
if the hilite of btn "WalkIn" then
put "Walk-IN" into tLoc
end if
put tQtty &TAB& tType &TAB& tLoc &TAB& short Time &TAB& short Date into tNewInputData
put the pgText of widget "PgridGallon" of stack "StackGallons" into tOldData
if tOldData is empty then
put tNewInputData into tOldData
else
put cr & tNewInputData after tOldData
end if
set the pgText of widget "PgridGallon" of stack "StackGallons" to tOldData
end if
repeat for each key tkey in tOldData // i just got this code from the dictionary
put tOldData [tkey]["cQtty"] into tQtty
// i'm stuck here I don't what's next code
end checkData
this past days i tried using field and repeat to get the sum thanks for those who share their knowledge in that topic.
...
repeat for each key tkey in tOldData // i just got this code from the dictionary
put tOldData [tkey]["cQtty"] into tQtty
add tQtty to tTotalSum
end repeat
...
I'm not sure WHERE exactly you want to display the tTotalSum in the end?
Looking at your code, keep in mind that you are using pgText not pgData. With pgText, think lines and items not arrays, elements and keys like you would with pgData. So, in lieu of that I would use something like this, assuming that the quantity column is the first column and you have no invisible columns before it:
I would say a PolyGrid is easier to create and manage, but a datagrid is a bit more powerful but has also a very steep leraning curve!
E.g. the user can modify text by doubleclicking a cell in a Datagrid (if the programmer allows), that is not possible with a PolyGrid.
As Klaus indicated, the polygrid is easier. Start with the polygrid and see if that fills your requirements. If not, then you can move to the datagrid. The datagrid is very powerful but can also be a bit fussy or slow at times so you really need to experiment in your learning process of the datagrid.
On you sorting, did you set the pgText of the polygrid with tOldData?