Page 1 of 1

Missing value error

Posted: Thu Jul 11, 2024 3:57 am
by florencepugh
I'm trying to calculate the total amount spent by a customer in my LiveCode database app. Here's the script I'm using:

Code: Select all

on calculateTotalSpent (customerName)
  local total := 0
  repeat with aRow in orders where customer = customerName
    put the amount of aRow into total
  end repeat
  return total
end calculateTotalSpent
When I run this script, I get an error message about "missing value." I think the problem is related to how I'm accessing the "amount" field in the orders table. Can someone help me fix this error?

Re: Missing value error

Posted: Thu Jul 11, 2024 4:42 am
by FourthWorld
GPTs are notoriously bad at pretending to know how to write LiveCode.

What are you working on?

Re: Missing value error

Posted: Thu Jul 11, 2024 7:54 am
by stam
Actually that code is bad even for chatGPT…

Re: Missing value error

Posted: Thu Jul 11, 2024 9:02 am
by richmond62
The OP is , supposedly, a first time poster.

I wonder how many first time posters jump in at the deep end to shark-infested waters?

Or, maybe, Bot-infested . . . LOL.

Re: Missing value error

Posted: Thu Jul 11, 2024 10:00 am
by FourthWorld
stam wrote:
Thu Jul 11, 2024 7:54 am
Actually that code is bad even for chatGPT…
Well, at least regenerative software has completely transformed gymnastics:
https://youtu.be/YwJIYj3hPAU

😁

Re: Missing value error

Posted: Thu Jul 11, 2024 2:41 pm
by dunbarx
Florence.

So is it true? You tried to run a GPT script in the real world? :D

What experience do you have with LiveCode?

In any case, the task at hand is simple, just give us a short description. It will likely take about ten lines of code, and you must have your data already stored somewhere.

Craig

Re: Missing value error

Posted: Thu Jul 11, 2024 2:59 pm
by stam
I think it might be the other way round: ChatGPT tried to run Florence in the forum :P :P :P :P :P

Re: Missing value error

Posted: Thu Jul 11, 2024 3:00 pm
by stam
FourthWorld wrote:
Thu Jul 11, 2024 10:00 am
Well, at least regenerative software has completely transformed gymnastics:
https://youtu.be/YwJIYj3hPAU
That's one scary video!!!!!!

Re: Missing value error

Posted: Thu Jul 11, 2024 3:03 pm
by Klaus
Hi Florence,

welcome to the forum!

Yes, that script looks cool, but will do nothing but throwing errors! :D
If you are using an SQLite or MySQL database, then you should use SQL,
since that will save you a lot of scripting in LC.

The SQL command for this is:

Code: Select all

...
### Replace ??? with the name of the column holding the amount of money:
SELECT SUM(???) FROM 'orders' WHERE 'customer' = 'customerName'
...
That will give you the TOTAL of that columns for the selected customer.
Hope that helps!

Best

Klaus

P.S.
Personal note:
A little "Hello" or something would not have hurt for the very first posting!

Re: Missing value error

Posted: Thu Jul 11, 2024 3:37 pm
by SparkOut
stam wrote:
Thu Jul 11, 2024 2:59 pm
I think it might be the other way round: ChatGPT tried to run Florence in the forum :P :P :P :P :P
This is funny! But also very true
:D