result of calculation stored in a datagrid, extracted as zero

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
CAsba
Posts: 368
Joined: Fri Sep 30, 2022 12:11 pm

result of calculation stored in a datagrid, extracted as zero

Post by CAsba » Fri Nov 10, 2023 1:47 pm

Hi,
I'm storing customer invoices in a datagrid. On some invoices, subject to a Prompt Payment Discount, is an advisory line of text - 'Pay only £304.88 within 14 days.' where the sum 304.88 is from a field, the result of a calculation, but 14 is from a field, but not the result of a calculation. The datagrid saves both figures in the line of text.
The problem arises when I recover the customer invoice (by invoice number); the line of text shows as 'Pay only £0.00 within 14 days.'.
Is it possible to set the line of text as text only to possibly avoid this problem ?

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9417
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: result of calculation stored in a datagrid, extracted as zero

Post by richmond62 » Fri Nov 10, 2023 1:51 pm

Is your end result composed of: £ + number + text + number + text ?

Or, is it composed of £344 + text + number + text ?

CAsba
Posts: 368
Joined: Fri Sep 30, 2022 12:11 pm

Re: result of calculation stored in a datagrid, extracted as zero

Post by CAsba » Fri Nov 10, 2023 2:07 pm

Hi Richmond62,
code]put "Pay only £" & fld "discountedtotal" of cd "doc2" & " within " & fld "days" of cd "doc2" & " days." into fld "vn5" of cd "doc2"[/code]
is the code for the line of text.
Field "discountedTotal" is the result of a calculation.
Regards,
CAsba.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9417
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: result of calculation stored in a datagrid, extracted as zero

Post by richmond62 » Fri Nov 10, 2023 2:21 pm

I presume you have checked what is going into fld "discountedtotal".

I also assume that BEFORE this:

Code: Select all

put "Pay only £" & fld "discountedtotal" of cd "doc2" & " within " & fld "days" of cd "doc2" & " days." into fld "vn5" of cd "doc2"
the calculation to dump a number into fld "discountedtotal" has already been performed.

CAsba
Posts: 368
Joined: Fri Sep 30, 2022 12:11 pm

Re: result of calculation stored in a datagrid, extracted as zero

Post by CAsba » Fri Nov 10, 2023 2:35 pm

Yes, your assumption is correct.
The line of text works ok when originally put onto the invoice; it is only when it is recovered from the datagrid that the problem occurs.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9417
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: result of calculation stored in a datagrid, extracted as zero

Post by richmond62 » Fri Nov 10, 2023 2:36 pm

Try using a table field instead of a datagrid.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9678
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: result of calculation stored in a datagrid, extracted as zero

Post by dunbarx » Fri Nov 10, 2023 3:27 pm

The issue cannot be what sort of control CAsba is using, it has to be a code issue. The line of code itself, modified for use in a test stack I made, works fine.

Since there are no calculations here to throw an error, there is something else going on.

Craig

CAsba
Posts: 368
Joined: Fri Sep 30, 2022 12:11 pm

Re: result of calculation stored in a datagrid, extracted as zero

Post by CAsba » Fri Nov 10, 2023 3:41 pm

Is there a way of manipulating the field "discountedtotal" so that there is no trace of it being a result of a calculation, something like...'set as text fld "discountedtotal" or similar ?

stam
Posts: 2692
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: result of calculation stored in a datagrid, extracted as zero

Post by stam » Fri Nov 10, 2023 4:37 pm

What I would suggest is that you store the invoice amount in its own key/column (this does need to be visible).
If you want to show the text
Pay <invoiceAmount> within <intervalDays> days
you could show that by constructing the sentence in the fillinData handler of the row/column behaviour of the visible column, which would be for decoration only, because the amount and interval are stored in hidden keys.

That way you always have easy access to the invoice amount but you only show the full sentence, if that makes sense?

CAsba
Posts: 368
Joined: Fri Sep 30, 2022 12:11 pm

Re: result of calculation stored in a datagrid, extracted as zero

Post by CAsba » Mon Nov 13, 2023 11:35 am

Hi everyone,
First thing I have to say is "sorry" for wasting your time (again!); I discovered what was causing the prob - some troublesooting coding that I hadn't deleted got in the way. I'm really full of remorse for not properly checking before I burst into print on the forum. As it turned out, there was a positive outcome.
Once again, guys, sorry to take up your valuable time and mental energy.
CAsba

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7241
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: result of calculation stored in a datagrid, extracted as zero

Post by jacque » Mon Nov 13, 2023 5:59 pm

No problem, I've done much worse. It's embarrassing. I think we've all been there.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”