1. Entering Time Values
- Posted by Irv <irv at ELLIJAY.COM> May 24, 1998
- 639 views
At 09:58 AM 5/24/98 -0400, you wrote: >...if I am referencing the sequence, I don't know whether the user >has entered 8:15, 20:15, or 08:15. I don't know what my first two >elements will be. >Of course, I can force the user to enter hh:mm, but I want to >make my program as...well, easy as possible. sequence tyme -- can't use the word 'time' as a var. tyme = gets(0) if find(':',tyme) = 2 then tyme = '0' & tyme -- look for colon position end if puts(1,tyme) Regards, Irv
2. Entering Time Values
- Posted by Alan Tu <ATU5713 at COMPUSERVE.COM> May 24, 1998
- 604 views
Irv, My tyme sequence in effect would be: {"1","0",":","3","0"} if I enter the tyme as 10:30. But date[4..5] =3D {10,30}. How do I compare the two? As you can see, tyme is just digits, while date() are thetrue values. I can't even use &. In Euphoria, can I combine two atoms of a sequence int= o one atom? --Alan =
3. Re: Entering Time Values
- Posted by Einar Mogen <nord.staernes at ROLLAG.MAIL.TELIA.COM> May 24, 1998
- 614 views
>Irv, > >My tyme sequence in effect would be: > >{"1","0",":","3","0"} if I enter the tyme as 10:30. But date[4..5] = >{10,30}. How do I compare the two? > >As you can see, tyme is just digits, while date() are thetrue values. I >can't even use &. In Euphoria, can I combine two atoms of a sequence into >one atom? > >--Alan I believe that the routine you should be looking at is value(). include get.e sequence value_return integer hour, minutes value_return = value(tyme[1..2]) hour = value[2] -- hour is now 10 value_return = value(tyme[4..5]) minutes = value[2] -- minutes is now 30 value() checks if a string can be converted into a value, and returns a two element sequence, the first element tells if it was succesful, and the second gives the number it found. (Maybe lousy explenation, but I hope you see what I mean) And here is the compare: If compare({hour,minutes},date[4..5]) = 0 then -- if no difference -- woohoo, they match! end if Hope I did not say anything wrong now... No code is tested. Einar Mogen
4. Re: Entering Time Values
- Posted by Alan Tu <ATU5713 at COMPUSERVE.COM> May 24, 1998
- 601 views
Einar, You did fine. I'm going out now, but your code makes sense. Boy, there = is nothing Euphoria cannot do! --Alan =
5. Re: Entering Time Values
- Posted by Monty King <boot_me at GEOCITIES.COM> May 25, 1998
- 634 views
Einar I looked all over for that routine when I was writing the internet starter that is on my webpage. I finally gave up on a built in conversion and wrote one that changed time values from Date into actual time elements. Monty
6. Re: Entering Time Values
- Posted by isaac <isaaca at MINDSPRING.COM> May 24, 1998
- 612 views
Alan, try filtering tyme through this before comparing: tyme={value(tyme[1..2]),value(tyme[4..5])} tyme={tyme[1][2],tyme[2][2]}
7. Re: Entering Time Values
- Posted by isaac <isaaca at MINDSPRING.COM> May 24, 1998
- 598 views
oops, the problems already been solved. That's what I get for posting before I finish reading all my mail.
8. Re: Entering Time Values
- Posted by Irv <irv at ELLIJAY.COM> May 24, 1998
- 610 views
Here's another way to do what you want: sequence now sequence lunchtime now = date() now = sprintf("%02d:%02d"&10,now[4..5]) puts(1,"The current time is: "&now) puts(1,"What time would you like to eat? ") lunchtime = gets(0) if find(':',lunchtime) = 2 then lunchtime = '0' & lunchtime end if if compare(now,lunchtime) = 0 then puts(1,"Let's Eat!") else puts(1,"OK, wait until "&lunchtime) end if Regards, Irv