What is the easiest control to use for my project? [SOLVED]

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

karmacomposer
Posts: 361
Joined: Wed Apr 27, 2011 2:12 pm

What is the easiest control to use for my project? [SOLVED]

Post by karmacomposer » Fri Aug 29, 2014 1:23 pm

I have to read a database table and import data from a PayPal field. I need to extract only a few pieces of info from this list and show a few columns of data.

The data grid has been a pain in my royal tush, so is it better to use a multiline table field and if so, how do I put data on specific lines - but all data is in an array and it will constantly be added to.

The data grid seemed perfect, but is proving to be impossible to work with. I read ALL the documentation, watched all the videos, read all the tutorials. Does not matter. It's easy to put hard coded data into it, but reading from a database table where the data is all jumbled together (paypal does this) and then attempting to extract what I need has proved to be futile.

I already tried the split command, tried the keys repeat loop, tried pData, etc. nothing has worked for me.

I have been able to kind of get what I need to multiline text boxes, but it's very ugly and not very functional.

What is my easiest, yet best option.

Thanks.

Mike
Last edited by karmacomposer on Sun Sep 07, 2014 2:45 am, edited 1 time in total.

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

Re: What is the easiest control to use for my project?

Post by Klaus » Fri Aug 29, 2014 1:41 pm

Hi Mike,

could give a short example, please?
Datagrids ARE ugly beasts, but tamable ones :D


Best

Klaus

karmacomposer
Posts: 361
Joined: Wed Apr 27, 2011 2:12 pm

Re: What is the easiest control to use for my project?

Post by karmacomposer » Fri Aug 29, 2014 2:54 pm

Here is the current app:

Main (connect to the database and attempt to get specific order information a la grid, as well as cumulative sales tax and payouts):

Image

Link if you want to see the entire image: http://www.mfelkerco.com/pictures/gccasdbapp.jpg

Card 2 (for me to see the raw data from the paypal table of the shopping cart):

Image

Link if you want to see the entire image: http://www.mfelkerco.com/pictures/gccasdbapp_pg2.jpg

I want to replace the grid in Main with something easier to show data in. Also, as it stands now, the repeat loop with the array is achingly slow - how can I speed all this up? The orders are always added to, so the total number of orders will rarely be the same, but the first order will always be 1 (not sure how to capture that piece of data since there is no field when stripped).

Mike

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

Re: What is the easiest control to use for my project?

Post by Klaus » Fri Aug 29, 2014 3:04 pm

Hi Mike,
the repeat loop with the array is achingly slow - how can I speed all this up?
still do not see the whole picture but please post the script you use for this!


Best

Klaus

karmacomposer
Posts: 361
Joined: Wed Apr 27, 2011 2:12 pm

Re: What is the easiest control to use for my project?

Post by karmacomposer » Fri Aug 29, 2014 3:48 pm

Klaus wrote:Hi Mike,
the repeat loop with the array is achingly slow - how can I speed all this up?
still do not see the whole picture but please post the script you use for this!


Best

Klaus
Sure! It's a beast.

The button BEGIN SESSION logs into the database (this one works perfectly).

Code: Select all

on mouseUp
    -- use a global variable to hold the connection ID so other scripts can use it
    global gConnectionID
    
    -- set up the connection parameters - edit these to suit your database
    put "URL" into tDatabaseAddress
    put "DATABASE NAME" into tDatabaseName
    put "USERNAME" into tDatabaseUser
    put "PASSWORD" into tDatabasePassword
    
    Put "" into Data
    
    -- connect to the database
    put revOpenDatabase("MySQL", tDatabaseAddress, tDatabaseName, tDatabaseUser, tDatabasePassword) into tResult
    
    -- check if it worked and display an error message if it didn't
    -- & set the connection ID global
    if tResult is a number then
        put tResult into gConnectionID
        --answer info "Connected to the database." & cr & "Connection ID = " & gConnectionID
        put "DB On" & " ID=" & gConnectionID into field "fldDBon"
    else
        put empty into gConnectionID
        --answer error "Unable to connect to the database:" & cr & tResult
        put "DB Off" & tResult into field "fldDBon"
    end if
end mouseUp
This is the script for DETERMINE PAYOUT (the main point of this entire project - this one DOES NOT work):

Code: Select all

on mouseUp
   -- check the global connection ID to make sure we have a database connection
   global gConnectionID
   if gConnectionID is not a number then
      answer error "Please connect to the database first."
      exit to top
   end if
   
   global Totals
   put "0.00" into Totals
   put "0" into tTotalNumItems
   put "1" into theLine
   Put "0" into theCount
   put false into firstLineContainsColumnNames
   
   -- construct the SQL (this selects all the data from the specified table) 
   put "gccas38_paypal" into tTableName    -- set this to the name of a table in your database
   put "SELECT * FROM " & tTableName into tSQL
   
   -- query the database
   put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData
   
   -- check the result and display the data or an error message
   if item 1 of tData = "revdberr" then
      answer error "There was a problem querying the database:" & cr & tData
   else
      
      put "" into field "fldCount"
      put "" into field "fldDBon"
      
      put tData into t -- fld 1 contains your data
      put urldecode(t) into t
      split t by "&" and "="
      
      --===================================
      --Main Loop
      --===================================
      
      repeat for each line L in s -- tData is all 248 orders, one per line
         put theCount into field "fldCount"
         put s into field "fldDump"
         add "1" to theCount
      processData L -- "L" will contain the data block for  one order; i.e., one Paypal line
   end repeat
   answer "Done"
   end if
end mouseUp

--===================================
--Function to process data
--===================================

on processData pData -- pData is one order
   repeat for each key k in t -- loop through each key
         if tData["order_id"] contains "PENDING" then next repeat -- ignore this one
         -- Process Data
            
         put k["payment_date"] into theStuff[theLine]["datePurchase"]
         put k["payment_date"] into field "fldDataDump"
         
         put tData["quantity"] into theStuff[theLine]["quantity"]
         put tData["quantity"] into field "fldDataDump"
         
         put tData["shipping"] into theStuff[theLine]["Shipping"]
         put tData["shipping"] into field "fldDataDump"
         
         put tData["tax"] into theStuff[theLine]["Tax"]
         put tData["tax"] into field "fldDataDump"
         
         put tData["tax"] into tSalesTax
         
         put tData["num_cart_items"] into tNumItems
         put tData["num_cart_items"] into field "fldDataDump"
      
         put tPayoutAmt[tVarNum] into theStuff[theLine]["payout"]
         put tPayoutAmt[tVarNum] into field "fldDataDump"
         
         -- last item is shipping - get rid of it
      put tNumItems - 1 into tNumItems
      repeat with tVarNum = 1 to tNumItems
         put pData["item_name" & tVarNum] into tThingBought
         set the dgText ["itemPurchased"] of group "dgItems" to tThingBought
         put pData["quantity" & tVarNum] into tTotalNumItems
         
         --===================================
         --Begin Substitution Table
         --===================================
         --Hoodies and Sweatshirts
         --Heather Gray
         if tThingBought = "Heather Gray Zippered and Sweatshirt Hoodies Size Kids Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Zippered and Sweatshirt Hoodies Size Kids XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Zippered and Sweatshirt Hoodies Size Adult Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Zippered and Sweatshirt Hoodies Size Adult Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Zippered and Sweatshirt Hoodies Size Adult Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Zippered and Sweatshirt Hoodies Size Adult XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Zippered and Sweatshirt Hoodies Size Adult XXL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Maroon
         if tThingBought = "Maroon Zippered and Sweatshirt Hoodies Size Kids Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Zippered and Sweatshirt Hoodies Size Kids XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Zippered and Sweatshirt Hoodies Size Adult Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Zippered and Sweatshirt Hoodies Size Adult Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Zippered and Sweatshirt Hoodies Size Adult Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Zippered and Sweatshirt Hoodies Size Adult XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Zippered and Sweatshirt Hoodies Size Adult XXL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Royal Blue
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Kids Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Kids Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Kids Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Kids XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Adult Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Adult Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Adult Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Adult XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Adult XXL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Spirit Shirts
         --Gold
         if tThingBought = "Gold School Spirit Shirt Size Kids Extra Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Kids Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Kids Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Kids Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Kids XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Adult Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Adult Mediuml" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Adult Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Adult XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Adult XXL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Heather Gray
         if tThingBought = "Heather Gray School Spirit Shirt Size Kids Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray School Spirit Shirt Size Kids Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray School Spirit Shirt Size Kids XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray School Spirit Shirt Size Adult Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray School Spirit Shirt Size Adult Mediuml" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray School Spirit Shirt Size Adult Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray School Spirit Shirt Size Adult XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray School Spirit Shirt Size Adult XXL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Maroon
         if tThingBought = "Maroon School Spirit Shirt Size Kids Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon School Spirit Shirt Size Kids Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon School Spirit Shirt Size Kids XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon School Spirit Shirt Size Adult Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon School Spirit Shirt Size Adult Mediuml" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon School Spirit Shirt Size Adult Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon School Spirit Shirt Size Adult XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon School Spirit Shirt Size Adult XXL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Royal Blue
         if tThingBought = "Royal Blue School Spirit Shirt Size Kids Extra Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Kids Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Kids Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Kids Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Kids XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Adult Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Adult Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Adult Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Adult Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Adult XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Adult XXL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         -- Short Sleeve Polos
         --Gold
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 4" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 5" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 6" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 7" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 8" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 10" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 12" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 14" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 16" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 18" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 20" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Adult Small" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Royal Blue
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 4" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 5" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 6" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 7" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 8" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 10" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 12" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 14" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 16" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 18" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 20" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Adult Small" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Maroon
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Kids 12" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Kids 14" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Kids 16" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Kids 18" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Kids 20" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Adult Small" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Adult Medium" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Adult Large" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Adult XL" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Heather Gray
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Kids 12" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Kids 14" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Kids 16" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Kids 18" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Kids 20" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Adult Small" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Adult Medium" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Adult Large" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Adult XL" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Long Sleeve Polos
         --Gold
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Kids Extra Small" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Kids Small" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Kids Medium" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Kids Large" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Kids XL" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Adult Small" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Adult Medium" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Adult Large" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Adult XL" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Adult XXL" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Royal Blue
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Kids Extra Small" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Kids Small" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Kids Medium" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Kids Large" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Kids XL" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Adult Small" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Adult Medium" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Adult Large" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Adult XL" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Adult XXL" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Heather Gray
         if tThingBought = "Heather Gray Long Sleeve Polo Shirt Size Kids Large" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Long Sleeve Polo Shirt Size Kids XL" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Long Sleeve Polo Shirt Size Adult Small" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Long Sleeve Polo Shirt Size Adult Medium" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Long Sleeve Polo Shirt Size Adult Large" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Long Sleeve Polo Shirt Size Adult XL" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Long Sleeve Polo Shirt Size Adult XXL" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Maroon
         if tThingBought = "Maroon Long Sleeve Polo Shirt Size Kids Large" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Long Sleeve Polo Shirt Size Kids XL" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Long Sleeve Polo Shirt Size Adult Small" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Long Sleeve Polo Shirt Size Adult Medium" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Long Sleeve Polo Shirt Size Adult Large" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Long Sleeve Polo Shirt Size Adult XL" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Long Sleeve Polo Shirt Size Adult XXL" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --===================================
         --End of Substitution Table
         --===================================
         add tPayoutAmt[tVarNum] to field "fldPayoutAmount"
         add 1 to theLine
      end repeat
         
      add tSalesTax to field "fldSalesTaxToDate"
      set the dgData of group "dgItems" to theStuff
      add "1" to theLine
      
   end repeat
end processData
The button SHOW ALL ORDERS goes to card 2 and allows the user to see all orders in the database (this works perfectly).

Code: Select all

on mouseUp
    go to card "crdRawData"
end mouseUp
The button END SESSION logs out of the database and exits (this works perfectly).

Code: Select all

on mouseUp
    global gConnectionID
    
    -- if we have a connection, close it and clear the global connection ID
    if gConnectionID is a number then
        revCloseDatabase gConnectionID
        put empty into gConnectionID
        put empty into Data
        quit
    end if
end mouseUp
fldDataDump is just a throwaway field to let me see what's going on in the script. I'll delete it when this all works. Sames goes for fldCount.

The code above is my main problem.

Mike

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

Re: What is the easiest control to use for my project?

Post by Klaus » Fri Aug 29, 2014 3:56 pm

OK, a quick glance shows the "bottleneck": Do not access FIELDS in a repeat loop! 8)

Collect all data into a variable and fill your field(s) in the end "en bloc"!

You will need to look VERY fast to see the progress in your fields anyway, if you leave this out,
everything will be as fast as hell, so there is no need to display any progress! :D

karmacomposer
Posts: 361
Joined: Wed Apr 27, 2011 2:12 pm

Re: What is the easiest control to use for my project?

Post by karmacomposer » Fri Aug 29, 2014 3:59 pm

I am having a hard time understanding this. I have to cycle through all the lines of the data (which change all the time as new orders are added) and put items into the array.

How do I then display the data I need to display?

Is this better:

Code: Select all

on mouseUp
   -- check the global connection ID to make sure we have a database connection
   global gConnectionID
   if gConnectionID is not a number then
      answer error "Please connect to the database first."
      exit to top
   end if
   
   global Totals
   put "0.00" into Totals
   put "0" into tTotalNumItems
   put "1" into theLine
   Put "0" into theCount
   put false into firstLineContainsColumnNames
   
   -- construct the SQL (this selects all the data from the specified table) 
   put "gccas38_paypal" into tTableName    -- set this to the name of a table in your database
   put "SELECT * FROM " & tTableName into tSQL
   
   -- query the database
   put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData
   
   -- check the result and display the data or an error message
   if item 1 of tData = "revdberr" then
      answer error "There was a problem querying the database:" & cr & tData
   else
      
      put "" into field "fldDBon"
      
      put tData into t -- fld 1 contains your data
      put urldecode(t) into t
      split t by "&" and "="
      
      --===================================
      --Main Loop
      --===================================
      
      repeat for each line L in s -- tData is all 248 orders, one per line
         add "1" to theCount
      processData L -- "L" will contain the data block for  one order; i.e., one Paypal line
   end repeat
   answer "Done"
   end if
end mouseUp

--===================================
--Function to process data
--===================================

on processData pData -- pData is one order
   repeat for each key k in t -- loop through each key
         if tData["order_id"] contains "Pending" then next repeat -- ignore this one
         -- Process Data
            
         put tData["payment_date"] into theStuff[theLine]["datePurchase"]
         put tData["quantity"] into theStuff[theLine]["quantity"]
         put tData["shipping"] into theStuff[theLine]["Shipping"]
         put tData["tax"] into theStuff[theLine]["Tax"]
         put tData["tax"] into tSalesTax
         put tData["num_cart_items"] into tNumItems
         put tPayoutAmt[tVarNum] into theStuff[theLine]["payout"]
         
         -- last item is shipping - get rid of it
      put tNumItems - 1 into tNumItems
      repeat with tVarNum = 1 to tNumItems
         put pData["item_name" & tVarNum] into tThingBought
         set the dgText ["itemPurchased"] of group "dgItems" to tThingBought
         put pData["quantity" & tVarNum] into tTotalNumItems
         
         --===================================
         --Begin Substitution Table
         --===================================
         --Hoodies and Sweatshirts
         --Heather Gray
         if tThingBought = "Heather Gray Zippered and Sweatshirt Hoodies Size Kids Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Zippered and Sweatshirt Hoodies Size Kids XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Zippered and Sweatshirt Hoodies Size Adult Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Zippered and Sweatshirt Hoodies Size Adult Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Zippered and Sweatshirt Hoodies Size Adult Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Zippered and Sweatshirt Hoodies Size Adult XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Zippered and Sweatshirt Hoodies Size Adult XXL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Maroon
         if tThingBought = "Maroon Zippered and Sweatshirt Hoodies Size Kids Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Zippered and Sweatshirt Hoodies Size Kids XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Zippered and Sweatshirt Hoodies Size Adult Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Zippered and Sweatshirt Hoodies Size Adult Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Zippered and Sweatshirt Hoodies Size Adult Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Zippered and Sweatshirt Hoodies Size Adult XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Zippered and Sweatshirt Hoodies Size Adult XXL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Royal Blue
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Kids Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Kids Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Kids Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Kids XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Adult Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Adult Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Adult Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Adult XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Zippered and Sweatshirt Hoodies Size Adult XXL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Spirit Shirts
         --Gold
         if tThingBought = "Gold School Spirit Shirt Size Kids Extra Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Kids Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Kids Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Kids Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Kids XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Adult Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Adult Mediuml" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Adult Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Adult XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold School Spirit Shirt Size Adult XXL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Heather Gray
         if tThingBought = "Heather Gray School Spirit Shirt Size Kids Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray School Spirit Shirt Size Kids Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray School Spirit Shirt Size Kids XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray School Spirit Shirt Size Adult Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray School Spirit Shirt Size Adult Mediuml" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray School Spirit Shirt Size Adult Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray School Spirit Shirt Size Adult XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray School Spirit Shirt Size Adult XXL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Maroon
         if tThingBought = "Maroon School Spirit Shirt Size Kids Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon School Spirit Shirt Size Kids Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon School Spirit Shirt Size Kids XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon School Spirit Shirt Size Adult Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon School Spirit Shirt Size Adult Mediuml" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon School Spirit Shirt Size Adult Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon School Spirit Shirt Size Adult XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon School Spirit Shirt Size Adult XXL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Royal Blue
         if tThingBought = "Royal Blue School Spirit Shirt Size Kids Extra Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Kids Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Kids Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Kids Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Kids XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Adult Small" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Adult Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Adult Medium" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Adult Large" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Adult XL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue School Spirit Shirt Size Adult XXL" then 
            put "4.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         -- Short Sleeve Polos
         --Gold
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 4" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 5" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 6" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 7" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 8" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 10" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 12" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 14" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 16" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 18" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Kids 20" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Short Sleeve Polo Shirt Size Adult Small" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Royal Blue
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 4" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 5" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 6" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 7" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 8" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 10" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 12" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 14" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 16" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 18" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Kids 20" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Short Sleeve Polo Shirt Size Adult Small" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Maroon
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Kids 12" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Kids 14" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Kids 16" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Kids 18" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Kids 20" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Adult Small" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Adult Medium" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Adult Large" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Short Sleeve Polo Shirt Size Adult XL" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Heather Gray
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Kids 12" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Kids 14" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Kids 16" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Kids 18" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Kids 20" then 
            put "1.80" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Adult Small" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Adult Medium" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Adult Large" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Short Sleeve Polo Shirt Size Adult XL" then 
            put "2.40" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Long Sleeve Polos
         --Gold
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Kids Extra Small" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Kids Small" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Kids Medium" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Kids Large" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Kids XL" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Adult Small" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Adult Medium" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Adult Large" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Adult XL" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Gold Long Sleeve Polo Shirt Size Adult XXL" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Royal Blue
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Kids Extra Small" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Kids Small" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Kids Medium" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Kids Large" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Kids XL" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Adult Small" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Adult Medium" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Adult Large" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Adult XL" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Royal Blue Long Sleeve Polo Shirt Size Adult XXL" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Heather Gray
         if tThingBought = "Heather Gray Long Sleeve Polo Shirt Size Kids Large" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Long Sleeve Polo Shirt Size Kids XL" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Long Sleeve Polo Shirt Size Adult Small" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Long Sleeve Polo Shirt Size Adult Medium" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Long Sleeve Polo Shirt Size Adult Large" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Long Sleeve Polo Shirt Size Adult XL" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Heather Gray Long Sleeve Polo Shirt Size Adult XXL" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --Maroon
         if tThingBought = "Maroon Long Sleeve Polo Shirt Size Kids Large" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Long Sleeve Polo Shirt Size Kids XL" then 
            put "3.70" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Long Sleeve Polo Shirt Size Adult Small" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Long Sleeve Polo Shirt Size Adult Medium" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Long Sleeve Polo Shirt Size Adult Large" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Long Sleeve Polo Shirt Size Adult XL" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         if tThingBought = "Maroon Long Sleeve Polo Shirt Size Adult XXL" then 
            put "2.00" * tTotalNumItems into tPayoutAmt[tVarNum]
         end if
         
         --===================================
         --End of Substitution Table
         --===================================
         add tPayoutAmt[tVarNum] to tTotalPayout
         add 1 to theLine
      end repeat
         
      add tSalesTax to tTotalSalesTax
      add "1" to theLine
      
   end repeat
   
   set the dgData of group "dgItems" to theStuff
   put tTotalPayout into the field "fldPayoutAmount"
   put tTotalSalesTax into the field "fldSalesTaxtoDate"
   
end processData
Yep - that runs a zillion times faster. No results - nothing shows in the data grid - but it runs a zillion times faster.

Mike

karmacomposer
Posts: 361
Joined: Wed Apr 27, 2011 2:12 pm

Re: What is the easiest control to use for my project?

Post by karmacomposer » Fri Aug 29, 2014 8:51 pm

Klaus? Anyone? I really need help with this - once I know how to correctly gather the data and display it on the grid, I can finish this.

Mike

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: What is the easiest control to use for my project?

Post by jacque » Fri Aug 29, 2014 9:04 pm

When the loop is finished, go through your final array and put the values in the fields. That accesses each field only once, rather than multiple times within the repeat loop.

You can speed it up a little more by changing the substitution lookup. The way it's written, every "if" clause will run, even when a match has already been made. A better way to write those is to allow the engine to skip everything after a match:

Code: Select all

if tThingBought = "XXX" then 
  -- process
else if tThingBought = "YYY" then 
  -- process
else if tThingBought = "ZZZ" then 
  -- process
end if
After a match is found, the "else" causes all the rest of the "ifs" to be skipped and the engine will drop down to the next line after "end if".

But with a list of items as long as yours, if/else statements aren't the best choice. You could shorten the amount of code by using a switch construct instead. Switch allows you to list many possible matches that share the same processing instructions; that is, you could group all items with the same payout amounts instead of listing them each separately:

Code: Select all

switch tThingBought
  case "Heather Gray Zippered and Sweatshirt Hoodies Size Kids Large"
  case "Heather Gray Zippered and Sweatshirt Hoodies Size Kids XL"
  case "Heather Gray Zippered and Sweatshirt Hoodies Size Adult Small"
    put 4.00 * tTotalNumItems into tPayoutAmt[tVarNum]
    break
  case "Gold Short Sleeve Polo Shirt Size Kids 4"
  case "Gold Short Sleeve Polo Shirt Size Kids 5"
  case "Gold Short Sleeve Polo Shirt Size Kids 6"
    put 1.00 * tTotalNumItems into tPayoutAmt[tVarNum]
    break
  case ...

end switch
That should shorten your list by quite a bit. I removed the quotation marks that were around the dollar amounts. Quoted strings are literals, and by including quotes you are forcing the engine to convert the string to a number. If unquoted, the engine will assume it is already a number, which is marginally faster. It's a minor point, you won't notice a huge difference.

But...

If you hard-code these values into your script and the prices change, you have to make a new app. Even better than either of these suggestions is to read a text file on disk, or one you retrieve from the server. Put the text into a variable where you can look up the payout amount and reduce the entire substitution table to a couple of lines of code. Assuming the payout list is in a variable named "payouts", which has one sales item per line, followed by a comma and the payout amount:

Code: Select all

put line lineoffset(tThingBought,payouts) of payouts into tItem
put item 2 of tItem into tAmount
Then add tAmount to your total payouts. You can reduce that to a single line if you want:

Code: Select all

put item 2 of line lineoffset(tThingBought,payouts) of payouts into tAmount
If every item isn't specifically unique (though it looks like they are) then add "set wholematches to true" somewhere near the top of the handler. This will avoid spurious matches where one item matches only part of another, i.e., "heather shirt" would match "heather shirt small" if wholematches isn't true.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: What is the easiest control to use for my project?

Post by jacque » Fri Aug 29, 2014 9:10 pm

By the way, it looks like most of the field-intensive stuff is in your dataDump. The other fields aren't accessed that often. You can view the values of the variables in the variable watcher, without putting them into a field. I think if you just remove the data dump and keep an eye on the variable watcher, your script will run almost as fast as it does in your second iteration.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

karmacomposer
Posts: 361
Joined: Wed Apr 27, 2011 2:12 pm

Re: What is the easiest control to use for my project?

Post by karmacomposer » Fri Aug 29, 2014 9:42 pm

jacque wrote:By the way, it looks like most of the field-intensive stuff is in your dataDump. The other fields aren't accessed that often. You can view the values of the variables in the variable watcher, without putting them into a field. I think if you just remove the data dump and keep an eye on the variable watcher, your script will run almost as fast as it does in your second iteration.
Yes. I got rid of those fields already.

Mike

karmacomposer
Posts: 361
Joined: Wed Apr 27, 2011 2:12 pm

Re: What is the easiest control to use for my project?

Post by karmacomposer » Fri Aug 29, 2014 9:44 pm

Jacque,

Thank you for the advice. Quite good advice. These values are likely not going to change, but I am an idiot for not doing the if/else and the case is even better . . . DUH!

However, NO DATA is showing up in the data grid. Right now that is my number one priority. How do I get it to show up in the data grid? What am I doing wrong?

Here is the new code as case:

Code: Select all

on mouseUp
   -- check the global connection ID to make sure we have a database connection
   global gConnectionID
   if gConnectionID is not a number then
      answer error "Please connect to the database first."
      exit to top
   end if
   
   global Totals
   put "0.00" into Totals
   put 0 into tTotalNumItems
   put 1 into theLine
   Put 0 into theCount
   put false into firstLineContainsColumnNames
   
   -- construct the SQL (this selects all the data from the specified table) 
   put "gccas38_paypal" into tTableName    -- set this to the name of a table in your database
   put "SELECT * FROM " & tTableName into tSQL
   
   -- query the database
   put revDataFromQuery(tab, cr, gConnectionID, tSQL) into tData
   
   -- check the result and display the data or an error message
   if item 1 of tData = "revdberr" then
      answer error "There was a problem querying the database:" & cr & tData
   else
      
      put "" into field "fldDBon"
      
      put tData into t -- fld 1 contains your data
      put urldecode(t) into t
      split t by "&" and "="
      
      --===================================
      --Main Loop
      --===================================
      
      repeat for each line L in s -- tData is all 248 orders, one per line
         add 1 to theCount
      processData L -- "L" will contain the data block for  one order; i.e., one Paypal line
   end repeat
   answer "Done"
   end if
end mouseUp

--===================================
--Function to process data
--===================================

on processData pData -- pData is one order
   repeat for each key k in t -- loop through each key
         if tData["order_id"] contains "Pending" then next repeat -- ignore this one
         -- Process Data
            
         put tData["payment_date"] into theStuff[theLine]["datePurchase"]
         put tData["quantity"] into theStuff[theLine]["quantity"]
         put tData["shipping"] into theStuff[theLine]["Shipping"]
         put tData["tax"] into theStuff[theLine]["Tax"]
         put tData["tax"] into tSalesTax
         put tData["num_cart_items"] into tNumItems
         put tPayoutAmt[tVarNum] into theStuff[theLine]["payout"]
         
         -- last item is shipping - get rid of it
      put tNumItems - 1 into tNumItems
      repeat with tVarNum = 1 to tNumItems
         put pData["item_name" & tVarNum] into tThingBought
         set the dgText ["itemPurchased"] of group "dgItems" to tThingBought
         put pData["quantity" & tVarNum] into tTotalNumItems
         
         --===================================
         --Begin Substitution Table
         --===================================
         switch tThingBought
            --hoodies
  case "Heather Gray Zippered and Sweatshirt Hoodies Size Kids Large"
  case "Heather Gray Zippered and Sweatshirt Hoodies Size Kids XL"
  case "Heather Gray Zippered and Sweatshirt Hoodies Size Adult Small"
  case "Heather Gray Zippered and Sweatshirt Hoodies Size Adult Medium"
  case "Heather Gray Zippered and Sweatshirt Hoodies Size Adult Large"
  case "Heather Gray Zippered and Sweatshirt Hoodies Size Adult XL"
  case "Heather Gray Zippered and Sweatshirt Hoodies Size Adult XXL"
  case "Maroon Zippered and Sweatshirt Hoodies Size Kids Large"
  case "Maroon Zippered and Sweatshirt Hoodies Size Kids XL"
  case "Maroon Zippered and Sweatshirt Hoodies Size Adult Small"
  case "Maroon Zippered and Sweatshirt Hoodies Size Adult Medium"
  case "Maroon Zippered and Sweatshirt Hoodies Size Adult Large"
  case "Maroon Zippered and Sweatshirt Hoodies Size Adult XL"
  case "Maroon Zippered and Sweatshirt Hoodies Size Adult XXL"
  case "Royal Blue Zippered and Sweatshirt Hoodies Size Kids Small"
  case "Royal Blue Zippered and Sweatshirt Hoodies Size Kids Medium"
  case "Royal Blue Zippered and Sweatshirt Hoodies Size Kids Large"
  case "Royal Blue Zippered and Sweatshirt Hoodies Size Kids XL"
  case "Royal Blue Zippered and Sweatshirt Hoodies Size Adult Small"
  case "Royal Blue Zippered and Sweatshirt Hoodies Size Adult Medium"
  case "Royal Blue Zippered and Sweatshirt Hoodies Size Adult Large"
  case "Royal Blue Zippered and Sweatshirt Hoodies Size Adult XL"
  case "Royal Blue Zippered and Sweatshirt Hoodies Size Adult XXL"
     --Spirit Shirts
  case "Gold School Spirit Shirt Size Kids Extra Small"
  case "Gold School Spirit Shirt Size Kids Small"
  case "Gold School Spirit Shirt Size Kids Medium"
  case "Gold School Spirit Shirt Size Kids Large"
  case "Gold School Spirit Shirt Size Kids XL"
  case "Gold School Spirit Shirt Size Adult Small"
  case "Gold School Spirit Shirt Size Adult Medium"
  case "Gold School Spirit Shirt Size Adult Large"
  case "Gold School Spirit Shirt Size Adult XL"
  case "Gold School Spirit Shirt Size Adult XXL"
  case "Heather Gray School Spirit Shirt Size Kids Medium"
  case "Heather Gray School Spirit Shirt Size Kids Large"
  case "Heather Gray School Spirit Shirt Size Kids XL"
  case "Heather Gray School Spirit Shirt Size Adult Small"
  case "Heather Gray School Spirit Shirt Size Adult Medium"
  case "Heather Gray School Spirit Shirt Size Adult Large"
  case "Heather Gray School Spirit Shirt Size Adult XL"
  case "Heather Gray School Spirit Shirt Size Adult XXL"
  case "Maroon School Spirit Shirt Size Kids Medium"
  case "Maroon School Spirit Shirt Size Kids Large"
  case "Maroon School Spirit Shirt Size Kids XL"
  case "Maroon School Spirit Shirt Size Adult Small"
  case "Maroon School Spirit Shirt Size Adult Medium"
  case "Maroon School Spirit Shirt Size Adult Large"
  case "Maroon School Spirit Shirt Size Adult XL"
  case "Maroon School Spirit Shirt Size Adult XXL"
  case "Royal Blue School Spirit Shirt Size Kids Extra Small"
  case "Royal Blue School Spirit Shirt Size Kids Small"
  case "Royal Blue School Spirit Shirt Size Kids Medium"
  case "Royal Blue School Spirit Shirt Size Kids Large"
  case "Royal Blue School Spirit Shirt Size Kids XL"
  case "Royal Blue School Spirit Shirt Size Adult Small"
  case "Royal Blue School Spirit Shirt Size Adult Medium"
  case "Royal Blue School Spirit Shirt Size Adult Large"
  case "Royal Blue School Spirit Shirt Size Adult XL"
  case "Royal Blue School Spirit Shirt Size Adult XXL"
    put 4.00 * tTotalNumItems into tPayoutAmt[tVarNum]
    break
    --Short sleeve polos
  case "Gold Short Sleeve Polo Shirt Size Kids 4"
  case "Gold Short Sleeve Polo Shirt Size Kids 5"
  case "Gold Short Sleeve Polo Shirt Size Kids 6"
  case "Gold Short Sleeve Polo Shirt Size Kids 7"
  case "Gold Short Sleeve Polo Shirt Size Kids 8"
  case "Gold Short Sleeve Polo Shirt Size Kids 10"
  case "Gold Short Sleeve Polo Shirt Size Kids 12"
  case "Gold Short Sleeve Polo Shirt Size Kids 14"
  case "Gold Short Sleeve Polo Shirt Size Kids 16"
  case "Gold Short Sleeve Polo Shirt Size Kids 18"
  case "Gold Short Sleeve Polo Shirt Size Kids 20"
  case "Royal Blue Short Sleeve Polo Shirt Size Kids 4"
  case "Royal Blue Short Sleeve Polo Shirt Size Kids 5"
  case "Royal Blue Short Sleeve Polo Shirt Size Kids 6"
  case "Royal Blue Short Sleeve Polo Shirt Size Kids 7"
  case "Royal Blue Short Sleeve Polo Shirt Size Kids 8"
  case "Royal Blue Short Sleeve Polo Shirt Size Kids 10"
  case "Royal Blue Short Sleeve Polo Shirt Size Kids 12"
  case "Royal Blue Short Sleeve Polo Shirt Size Kids 14"
  case "Royal Blue Short Sleeve Polo Shirt Size Kids 16"
  case "Royal Blue Short Sleeve Polo Shirt Size Kids 18"
  case "Royal Blue Short Sleeve Polo Shirt Size Kids 20"
  case "Maroon Short Sleeve Polo Shirt Size Kids 12"
  case "Maroon Short Sleeve Polo Shirt Size Kids 14"
  case "Maroon Short Sleeve Polo Shirt Size Kids 16"
  case "Maroon Short Sleeve Polo Shirt Size Kids 18"
  case "Maroon Short Sleeve Polo Shirt Size Kids 20"
  case "Heather Gray Short Sleeve Polo Shirt Size Kids 12"
  case "Heather Gray Short Sleeve Polo Shirt Size Kids 14"
  case "Heather Gray Short Sleeve Polo Shirt Size Kids 16"
  case "Heather Gray Short Sleeve Polo Shirt Size Kids 18"
  case "Heather Gray Short Sleeve Polo Shirt Size Kids 20"
     put 1.80 * tTotalNumItems into tPayoutAmt[tVarNum]
     break
     --Adult sized Short Sleeve Polos
  case "Gold Short Sleeve Polo Shirt Size Adult Small"
  case "Royal Blue Short Sleeve Polo Shirt Size Adult Small"
     case "Maroon Short Sleeve Polo Shirt Size Adult Small"
    case "Maroon Short Sleeve Polo Shirt Size Adult Medium"
    case "Maroon Short Sleeve Polo Shirt Size Adult Large"
    case "Maroon Short Sleeve Polo Shirt Size Adult XL"
    case "Heather Gray Short Sleeve Polo Shirt Size Adult Small"
    case "Heather Gray Short Sleeve Polo Shirt Size Adult Medium"
    case "Heather Gray Short Sleeve Polo Shirt Size Adult Large"
    case "Heather Gray Short Sleeve Polo Shirt Size Adult XL"
    put 2.40 * tTotalNumItems into tPayoutAmt[tVarNum]
    break
    --Long Sleve Polos
 case "Gold Long Sleeve Polo Shirt Size Kids Extra Small"
 case "Gold Long Sleeve Polo Shirt Size Kids Small"
 case "Gold Long Sleeve Polo Shirt Size Kids Medium"
 case "Gold Long Sleeve Polo Shirt Size Kids Large"
 case "Gold Long Sleeve Polo Shirt Size Kids XL"
 case "Royal Blue Long Sleeve Polo Shirt Size Kids Extra Small"
 case "Royal Blue Long Sleeve Polo Shirt Size Kids Small"
 case "Royal Blue Long Sleeve Polo Shirt Size Kids Medium"
 case "Royal Blue Long Sleeve Polo Shirt Size Kids Large"
 case "Royal Blue Long Sleeve Polo Shirt Size Kids XL"
 case "Heather Gray Long Sleeve Polo Shirt Size Kids Large"
 case "Heather Gray Long Sleeve Polo Shirt Size Kids XL"
 case "Maroon Long Sleeve Polo Shirt Size Kids Large"
 case "Maroon Long Sleeve Polo Shirt Size Kids XL"
    put 3.70 * tTotalNumItems into tPayoutAmt[tVarNum]
    break
    --Adult Size Long Sleeve Polos
 case "Gold Long Sleeve Polo Shirt Size Adult Small"
 case "Gold Long Sleeve Polo Shirt Size Adult Medium"
 case "Gold Long Sleeve Polo Shirt Size Adult Large"
 case "Gold Long Sleeve Polo Shirt Size Adult XL"
 case "Gold Long Sleeve Polo Shirt Size Adult XXL"
 case "Royal Blue Long Sleeve Polo Shirt Size Adult Small"
 case "Royal Blue Long Sleeve Polo Shirt Size Adult Medium"
 case "Royal Blue Long Sleeve Polo Shirt Size Adult Large"
 case "Royal Blue Long Sleeve Polo Shirt Size Adult XL"
 case "Royal Blue Long Sleeve Polo Shirt Size Adult XXL"
 case "Heather Gray Long Sleeve Polo Shirt Size Adult Small"
 case "Heather Gray Long Sleeve Polo Shirt Size Adult Medium"
 case "Heather Gray Long Sleeve Polo Shirt Size Adult Large"
 case "Heather Gray Long Sleeve Polo Shirt Size Adult XL"
 case "Heather Gray Long Sleeve Polo Shirt Size Adult XXL"
    case "Maroon Long Sleeve Polo Shirt Size Adult Small"
 case "Maroon Long Sleeve Polo Shirt Size Adult Medium"
 case "Maroon Long Sleeve Polo Shirt Size Adult Large"
 case "Maroon Long Sleeve Polo Shirt Size Adult XL"
 case "Maroon Long Sleeve Polo Shirt Size Adult XXL"
    put 2.00 * tTotalNumItems into tPayoutAmt[tVarNum]
    break
     end switch
         --===================================
         --End of Substitution Table
         --===================================
         add tPayoutAmt[tVarNum] to tTotalPayout
         add 1 to theLine
      end repeat
         
      add tSalesTax to tTotalSalesTax
      add 1 to theLine
      
   end repeat
   
   set the dgData of group "dgItems" to theStuff
   put tTotalPayout into the field "fldPayoutAmount"
   put tTotalSalesTax into the field "fldSalesTaxtoDate"
   
end processData
It IS even faster, but no data shows on the data grid. HELP!

Mike

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

Re: What is the easiest control to use for my project?

Post by dunbarx » Fri Aug 29, 2014 11:00 pm

Hi.

"theStuff" seems to be assembled as a valid array, so the "dgData" is appropriate to load the DG. The next step is to put a breakpoint at the top of the block of code that loads that array variable, and make sure there is readable data in the array variable "tData".

Fortunately, the debugger displays array data in the clear while stepping through. Write back with what you find...

Craig Newman

karmacomposer
Posts: 361
Joined: Wed Apr 27, 2011 2:12 pm

Re: What is the easiest control to use for my project?

Post by karmacomposer » Fri Aug 29, 2014 11:29 pm

dunbarx wrote:The next step is to put a breakpoint at the top of the block of code that loads that array variable, and make sure there is readable data in the array variable "tData"
How do I do this?

Mike

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

Re: What is the easiest control to use for my project?

Post by dunbarx » Sat Aug 30, 2014 5:17 am

Mike.

You have never used the debugger, to step through the execution of a handler?

Craig

Post Reply