What is the easiest control to use for my project? [SOLVED]
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- Posts: 361
- Joined: Wed Apr 27, 2011 2:12 pm
Re: What is the easiest control to use for my project?
I've used it once or twice but I could not really decipher it. Yes, I know. I already read all the docs.
On the other hand, breakpoints are awesome. Just did not know about them till now. I have not coded in LiveCode that long and
took about 3 years off of using LiveCode.
Anyway, if I have a piece of text "sales_tax=5.60"
How do I isolate the 5.60 as a value and store it in a variable?
Thanks.
Mike
On the other hand, breakpoints are awesome. Just did not know about them till now. I have not coded in LiveCode that long and
took about 3 years off of using LiveCode.
Anyway, if I have a piece of text "sales_tax=5.60"
How do I isolate the 5.60 as a value and store it in a variable?
Thanks.
Mike
Re: What is the easiest control to use for my project?
Hi Mike,
that's an easy one:
...
put "sales_tax=5.60" into tVar
set itemdel to "="
put item 2 of tVar into tValueSalesTax
...
Best
Klaus
that's an easy one:
...
put "sales_tax=5.60" into tVar
set itemdel to "="
put item 2 of tVar into tValueSalesTax
...

Best
Klaus
Re: What is the easiest control to use for my project?
Hi Mike,
although I really prefer the solution that Jaqueline proposed (a list with name of: item TAB price)
here another hint to save a lot of typing.
Since many or all sizes of an item have the same price, you could save the SIZE check and script something like this:
Get the picture?
Best
Klaus
although I really prefer the solution that Jaqueline proposed (a list with name of: item TAB price)
here another hint to save a lot of typing.
Since many or all sizes of an item have the same price, you could save the SIZE check and script something like this:
Code: Select all
...
switch
case tThingBought begins with "Heather Gray Zippered and Sweatshirt Hoodies Size Kids"
case tThingBought begins with "Maroon Zippered and Sweatshirt Hoodies Size Kids"
case tThingBought begins with "Royal Blue Zippered and Sweatshirt Hoodies Size Kids"
case tThingBought begins with "Gold School Spirit Shirt Size Kids"
case tThingBought begins with "Heather Gray School Spirit Shirt Size Kids"
etc...
Best
Klaus
Re: What is the easiest control to use for my project?
Hi Mike,
and here some hints to your datagrid stuff in your last script.
1. You cannot address a column in a datagrid like this:
...
set the dgText["itemPurchased"] of group "dgItems" to tThingBought
...
"the dgtext" will only accept ONE parameter in [], but that is not a column name or something!
AND setting "the dgtext" of a datagrid will replace the complete previous content!
2. You do this in a repeat loop, which means in every loop the content of your datagrid will be overwritten!
3. Sorry, still have no idea what "theStuff" will contain in the end, but is has to be an Array when used in "set the dgData of grp..."
Set a breakpoint at this line:
...
set the dgData of group "dgItems" to theStuff
...
and check the content of the array "theStuff" in the debugger.
Best
Klaus
and here some hints to your datagrid stuff in your last script.
1. You cannot address a column in a datagrid like this:
...
set the dgText["itemPurchased"] of group "dgItems" to tThingBought
...
"the dgtext" will only accept ONE parameter in [], but that is not a column name or something!
AND setting "the dgtext" of a datagrid will replace the complete previous content!
2. You do this in a repeat loop, which means in every loop the content of your datagrid will be overwritten!
3. Sorry, still have no idea what "theStuff" will contain in the end, but is has to be an Array when used in "set the dgData of grp..."
Set a breakpoint at this line:
...
set the dgData of group "dgItems" to theStuff
...
and check the content of the array "theStuff" in the debugger.
Best
Klaus
-
- Posts: 361
- Joined: Wed Apr 27, 2011 2:12 pm
Re: What is the easiest control to use for my project?
Thank you, however, why does the following give me a execution error:
Is the syntax wrong? t(tNum) holds each line of the array. I am using a if/then/else loop to process each necessary array line. The first finds out if the line has "payment_date" in it. If it does, it should now lop off "payment_date=" and just put the actual date in the array. Likewise, in the next if/then, if t(tNum) contains "tax" then it gives the result: "sales_tax=5.60". The answer you gave should lop off the "sales_tax=", right?
So why do I get function: error in function handler in the line put t(tNum) into taxVar? Can I not put two of these in a row. Eventually, there will be far more than two in the if/then/else loop.
Mike
Code: Select all
--====================================
--Main Loop
--====================================
put 1 into col1date
put 1 into col2tax
answer "Begin Processing Orders"
repeat with tNum = 1 to numlines
if t[tNum] contains "payment_date" then
put t(tNum) into payVar
set itemdel to "="
put item 2 of payVar into theStuff[theLine]["datePurchase"]
Put "Processing Order: " &OrderIDNum into field "lblInfo"
add 1 to col1date
add 1 to OrderIDNum
else
if t[tNum] contains "tax" then
put t(tNum) into taxVar
set itemdel to "="
put item 2 of taxVar into theStuff[theLine]["Tax"]
put item 2 of taxVar into tSalesTax
add 1 to col2tax
end if
end if
So why do I get function: error in function handler in the line put t(tNum) into taxVar? Can I not put two of these in a row. Eventually, there will be far more than two in the if/then/else loop.
Mike
Re: What is the easiest control to use for my project?
Mike.
Make a new button. Put this into its script:
Place a breakpoint at the "repeat with..." line. Do you know how to do this? You can click in the narrow column that contains the line numbers, and set a small green circle at that point, or you can place the command "breakPoint" at any line within your script. But for now, just click on the line number (line 2).
Click the button. You are now in debug mode, a sub-environment of LC, and you can step through your handler. Make sure you are using the "variable" pane. Examine the small icons at the top left of the debugger window. Hover over each and see the tooltip that comes up. Play around. But you will see the values of your handler as you step through. Note that the array, normally invisible without massaging, is displayed as a hierarchal "pullDown" in the variable pane. Note you can create a separate window for any variable, and watch it change as you step through. Write back. You need to have this tool be second nature.
Craig
Make a new button. Put this into its script:
Code: Select all
on mouseUp
repeat with y = 1 to 10
put y & "," & random(99) into temp
put y * 10 into testArray[y]
end repeat
end mouseUp
Click the button. You are now in debug mode, a sub-environment of LC, and you can step through your handler. Make sure you are using the "variable" pane. Examine the small icons at the top left of the debugger window. Hover over each and see the tooltip that comes up. Play around. But you will see the values of your handler as you step through. Note that the array, normally invisible without massaging, is displayed as a hierarchal "pullDown" in the variable pane. Note you can create a separate window for any variable, and watch it change as you step through. Write back. You need to have this tool be second nature.
Craig
Re: What is the easiest control to use for my project?
Shouldn't this read:
?
Code: Select all
...
if t[tNum] contains "payment_date" then
## put t(tNum) into payVar
put t[tNum] into payVar
...
-
- Posts: 361
- Joined: Wed Apr 27, 2011 2:12 pm
Re: What is the easiest control to use for my project?
OMG!!!!!!!! That's what programming till 4am does to you. I NEVER would have seen the () instead of the []Klaus wrote:Shouldn't this read:?Code: Select all
... if t[tNum] contains "payment_date" then ## put t(tNum) into payVar put t[tNum] into payVar ...
Sheesh!
That, of course, fixed it now that you pointed out my blunder. Where are my NECESSARY prescription eyeglasses? (think My Cousin Vinnie)
Mike
Last edited by karmacomposer on Sat Aug 30, 2014 4:13 pm, edited 2 times in total.
-
- Posts: 361
- Joined: Wed Apr 27, 2011 2:12 pm
Re: What is the easiest control to use for my project?
Going through the sales tax array, an error popped up because a paypal line had the word 'TAX' in it, but it was NOT the sales tax, as a result, it crashes because it cannot add the value.
Here is the list of sales tax numbers (scroll all the way down to see the problem):
At what it considers Order ID 80, you can see instead of a sales tax figure, we get a string of crap. However, the word TAX is embedded in this string. How do we test to make sure only NUMBERS are stored? Specifically monetary amounts (ie 5.60 with the decimal in place)?
The code to add these together is simple:
How do I fix this?
Mike
Here is the list of sales tax numbers (scroll all the way down to see the problem):
Code: Select all
5.60
6.44
7.14
2.80
11.20
11.27
2.38
8.33
5.60
7.84
7.49
0.00
0.00
0.00
0.00
0.00
0.00
0.00
14.98
2.38
8.33
8.33
5.60
6.30
5.60
9.03
5.60
8.68
11.20
11.20
4.06
3.57
8.12
8.19
11.90
6.23
17.64
14.98
2.38
0.00
0.00
0.00
0.00
0.00
0.00
0.00
11.20
9.80
8.47
7.98
0.00
0.00
0.00
0.00
0.00
8.47
5.60
8.33
12.46
6.44
7.49
6.44
6.09
4.76
11.90
11.20
5.60
8.68
7.28
15.26
4.76
4.69
6.93
8.54
5.95
11.20
5.95
11.55
5.60
6.44
7.98
3.22
3.57
6.44
11.20
5.60
5.60
3.22
11.20
2.38
3.22
5.60
4.41
11.13
6.16
5.95
5.60
5.60
KZX9VLWATAXE8
The code to add these together is simple:
Code: Select all
add tSalesTax to tTotalSalesTax
Mike
Last edited by karmacomposer on Sat Aug 30, 2014 4:36 pm, edited 2 times in total.
Re: What is the easiest control to use for my project?
Hi Mike,
Syntax is correct, so what exactly does not work?
Best
Klaus
Code: Select all
add tSalesTax to tTotalSalesTax
maybe you could be a TAD more precise?but that did not work.
Syntax is correct, so what exactly does not work?

Best
Klaus
-
- Posts: 361
- Joined: Wed Apr 27, 2011 2:12 pm
Re: What is the easiest control to use for my project?
Klaus,Klaus wrote:Hi Mike,
Code: Select all
add tSalesTax to tTotalSalesTax
maybe you could be a TAD more precise?but that did not work.
Syntax is correct, so what exactly does not work?![]()
Best
Klaus
I corrected myself when I realized it was a error due to a string creeping in (scroll all the way to the bottom to see the string).
Code: Select all
5.60
6.44
7.14
2.80
11.20
11.27
2.38
8.33
5.60
7.84
7.49
0.00
0.00
0.00
0.00
0.00
0.00
0.00
14.98
2.38
8.33
8.33
5.60
6.30
5.60
9.03
5.60
8.68
11.20
11.20
4.06
3.57
8.12
8.19
11.90
6.23
17.64
14.98
2.38
0.00
0.00
0.00
0.00
0.00
0.00
0.00
11.20
9.80
8.47
7.98
0.00
0.00
0.00
0.00
0.00
8.47
5.60
8.33
12.46
6.44
7.49
6.44
6.09
4.76
11.90
11.20
5.60
8.68
7.28
15.26
4.76
4.69
6.93
8.54
5.95
11.20
5.95
11.55
5.60
6.44
7.98
3.22
3.57
6.44
11.20
5.60
5.60
3.22
11.20
2.38
3.22
5.60
4.41
11.13
6.16
5.95
5.60
5.60
KZX9VLWATAXE8
How do I test to make sure it's a number and not a string?
Code: Select all
if tSalesTax <> a number then ???
Mike
Re: What is the easiest control to use for my project?
Hi Mike,
just give it a TRY, as you would in real life:
Best
Klaus
just give it a TRY, as you would in real life:
Code: Select all
...
## Simple TRY form without ERROR detexting/checking, but will do in your case
try
add tSalesTax to tTotalSalesTax
end try
...

Best
Klaus
-
- Posts: 361
- Joined: Wed Apr 27, 2011 2:12 pm
Re: What is the easiest control to use for my project?
Amazing.
Never even heard of the Try command.
Honestly, it does work, but adding up all the sales tax is not correct. It seems to be adding values even if it's a string????
It works. No crashes now. However, tTotalSalesTax seems to be WAY too high to be accurate. How would I throw out a sales tax array variable if it's NOT a number at all? Is that possible?
Pseudocode:
How would I actually structure that? The Try command kind of gives me a pass, like Visual Basic's On Error Resume Next command - keeps going regardless of the error.
Also, magically the datagrid started working (WOW!). The dates are perfect (kind of - they need to be converted to a normal, American data structure).
Not sure how to do that, although I suspect it is nearly identical to what you suggested with
For example:
Needs to be just Aug 05, 2014. I don't want or need the time and PDT.
Also the tax is also showing up on the grid, but the alignment (the lines they are on) is WAY off. I KNOW I am doing it wrong. How do I get the fields to align properly:
Any suggestions? Sorry for all the questions, but I am so excited to be getting somewhere. I cannot thank Klaus and all of you helping me out. Trust me, as you answer my questions, I am learning the 'right' way to do it in LiveCode. I come from other programming languages, so 'unlearning' them is quite difficult when you are so used to them, but I like LiveCode so much more!!
Mike
Never even heard of the Try command.
Honestly, it does work, but adding up all the sales tax is not correct. It seems to be adding values even if it's a string????
Code: Select all
if t[tNum] contains "tax" then
put t[tNum] into taxVar
set itemdel to "="
--This goes into the Data Grid Array
put item 2 of taxVar into theStuff[theLine]["Tax"]
-- This goes into a variable for a field that shows the total Sales Tax to Date
put item 2 of taxVar into tSalesTax
## Simple TRY form without ERROR detexting/checking, but will do in your case
try
add tSalesTax to tTotalSalesTax
put tTotalSalesTax into field "fldSalesTaxtoDate"
end try
put tSalesTax into line col2tax field "fldRawData2"
add 1 to col2tax
end if
Pseudocode:
Code: Select all
If tSalesTax <> a number than throw it out
Also, magically the datagrid started working (WOW!). The dates are perfect (kind of - they need to be converted to a normal, American data structure).
Not sure how to do that, although I suspect it is nearly identical to what you suggested with
Code: Select all
put t[tNum] into taxVar
set itemdel to "="
put item 2 of taxVar into theStuff[theLine]["Tax"]
For example:
Code: Select all
22:06:12 Aug 05, 2014 PDT
Also the tax is also showing up on the grid, but the alignment (the lines they are on) is WAY off. I KNOW I am doing it wrong. How do I get the fields to align properly:
Code: Select all
Each data chunk contains the following:
Date Purchased (just one item)
Items Purchased (there could be multiple items here)
Quantity (just one item)
Payout (aligns with Items Purchased)
Shipping (just one item)
Tax (just one item)
End of data chunk
Mike
Last edited by karmacomposer on Sat Aug 30, 2014 5:35 pm, edited 1 time in total.
Re: What is the easiest control to use for my project?
Hi Mike,
this is getting way too abstract to "cure" from afar
Maybe you can supply a sample stack with some example data, so we can check what's going on?
Best
Klaus
this is getting way too abstract to "cure" from afar

Maybe you can supply a sample stack with some example data, so we can check what's going on?
Best
Klaus
-
- Posts: 361
- Joined: Wed Apr 27, 2011 2:12 pm
Re: What is the easiest control to use for my project?
Klaus,Klaus wrote:Hi Mike,
this is getting way too abstract to "cure" from afar![]()
Maybe you can supply a sample stack with some example data, so we can check what's going on?
Best
Klaus
What is your email address and I will be happy to send you the project file. It has sensitive data in it, so I cannot just post it here (due to database access of my client). You can email me at mike at world-class-multimedia dot com.
Mike