Can't figure out repeat with error code
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Can't figure out repeat with error code
I'm having trouble with my script not executing. It returns an error message:
error in 'with' start condition expression
for this code:
repeat with n = 1 to howMany
In this script:
on createDates
global oneDate
-- clear fields
put "" into field "The Dates"
put field "Quantity" into howMany
-- create random dates
repeat with n = 1 to howMany
do createOneDate
put oneDate into line n of field "The Dates"
end repeat
end createDates
It executed successfully about a dozen times, then started generating the error code. I tried retyping it, quitting and rebooting, but the error condition persists.
Any suggestions?
error in 'with' start condition expression
for this code:
repeat with n = 1 to howMany
In this script:
on createDates
global oneDate
-- clear fields
put "" into field "The Dates"
put field "Quantity" into howMany
-- create random dates
repeat with n = 1 to howMany
do createOneDate
put oneDate into line n of field "The Dates"
end repeat
end createDates
It executed successfully about a dozen times, then started generating the error code. I tried retyping it, quitting and rebooting, but the error condition persists.
Any suggestions?
Re: Can't figure out repeat with error code
Welcome to this forum,
And thanks for this post I can help (english LiveCoders are often faster than me)
I don't understand your "do createOneDate" line. Is there a createOneDate message ?
Try this:
Best regards
Jean-Marc
And thanks for this post I can help (english LiveCoders are often faster than me)

I don't understand your "do createOneDate" line. Is there a createOneDate message ?
Try this:
Code: Select all
on createDates
put "" into field "The Dates"
put the value of field "Quantity" into howMany -- the value is safer when you need an integer
repeat with n = 1 to howMany
put createOneRandomDate() into line n of field "The Dates"
end repeat
end createDates
function createOneRandomDate
put the seconds into tSec
put random(tSec) into tDateSec
convert tDateSec to date
return tDateSec
end createOneRandomDate
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 10057
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Can't figure out repeat with error code
Where is the value of createOneDate defined? And do you really need "do" there? What should it be doing?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Can't figure out repeat with error code
Jean-Marc,
Thank you for your suggestions and your code. I've incorporated your code.
Your comment about using "the value of" in order to ensure that the quantity was an integer led me to the real issue: It turn out the Quantity field was holding a character string that couldn't be interpreted as a number. It was something akin to 30\n10 (\n as a line return).
Your help allowed me to fix the problem and move forward!
Thank you,
Ted
Thank you for your suggestions and your code. I've incorporated your code.
Your comment about using "the value of" in order to ensure that the quantity was an integer led me to the real issue: It turn out the Quantity field was holding a character string that couldn't be interpreted as a number. It was something akin to 30\n10 (\n as a line return).
Your help allowed me to fix the problem and move forward!
Thank you,
Ted
Re: Can't figure out repeat with error code
Ted,
Glad to help
I forgot to precise I don't know yet how dates work before 1/1/70.
Jean-Marc
Glad to help
I forgot to precise I don't know yet how dates work before 1/1/70.
Jean-Marc
https://alternatic.ch
-
- VIP Livecode Opensource Backer
- Posts: 10057
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Can't figure out repeat with error code
You don't. According to Unix (and subsequently Windows and Linux), time didn't exist before then.jmburnod wrote: I don't know yet how dates work before 1/1/70.

Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Can't figure out repeat with error code
Hi.
You can use negative seconds:
You can use negative seconds:
Code: Select all
on mouseUp
get -1696666622 --March 1916
convert it to date
answer it
end mouseUp
Re: Can't figure out repeat with error code
Hi Craig,
Thanks fo the hint.
What about date before 0 ?
I tried :
The result is -111696666622
Thanks fo the hint.
What about date before 0 ?
I tried :
Code: Select all
on mouseUp
get -111696666622 -- ???
convert it to date
answer it --
end mouseUp
https://alternatic.ch
Re: Can't figure out repeat with error code
Jean Marc.
You have too much negative time on your hands.
I tried this with a button and a field:
The dates seem valid back to about the year 1000 or so. I did not parse the centuries in the field output, though it would be fun (gasp!) to do so. The value "325" is the max this particular handler will go using increments of 100,000,000 seconds, or about 3 years. It would be a hoot to find the actual second where the process breaks down, and you get those useless strings of digits instead of a date.
Challenge, anyone?
Craig
EDIT.
See a new thread about this ("Big Bang"), which is off-topic from the OP.
You have too much negative time on your hands.
I tried this with a button and a field:
Code: Select all
on mouseUp
repeat with y = 1 to 325
get -100000000 * y
convert it to date
put it into line y of temp
end repeat
put temp into fld 1
end mouseUp
Challenge, anyone?
Craig
EDIT.
See a new thread about this ("Big Bang"), which is off-topic from the OP.
Last edited by dunbarx on Tue Feb 23, 2016 10:36 pm, edited 1 time in total.