(No Subject)
- Posted by Mathew Hounsell <mat.hounsell at MAILEXCITE.COM> May 25, 1998
- 1077 views
[ Getting a Time of the User ] From the top of my head (Actual str_to_int isn't, it's one I know well) ... I know this was solved, but I wrote it before I finished the digest, silly me. -----<untested code>----- function str_to_int(sequence str) object val val = 0 for t = 1 to length(str) by 1 do if str[t] >= '0' and str[t] <= '9' then val = val * 10 + (str[t] - '0') else val = str exit end if end for return val end function function get_time_string() sequence val val = {} while 1 do puts(1,"Please enter the time in 24 Hr format. eg 23:06\n") val = gets(0) if length(val) = 10 then val = val[1..length(val)-1] end if if length(val) = 4 then val = '0' and val end if if length(val) = 5 then if val[3] = ':' then exit end if end if end while return val end function global function get_time() sequence str, val object tenp val = {0,0} while 1 do str = get_time_string() temp = str_to_int(str[1..2]) if integer(temp) then val[1] = temp -- hours temp = str_to_int(str[4..5]) if integer(temp) then val[2] = temp -- minutes end if end if end while return val end function -----<end snip>----- [ Concaternation (&) ] Alan wrote "In Euphoria, can I combine two atoms of a sequence into one atom?" Simplely: No. Rob defines the atom as the basic indivisable unit. Multiple atoms are sequences so &ing always produces sequences. Note this is a partial lie. You can use one atom as 3 bytes or 31 bits, if you want. [ Using print() and get() ] Just kidding about being the only one. ; ) [ Euphoria Compiler ] Martin wrote : "I'd be interested in the details. It seems to me that the engine that produces the code for the interpreter to send to the CPU could be easily modified to send the code to a file instead. Wouldn't that be a compiler?" I think people miss the main reason why Euphoria can't be compiled: The Sequence. It is a flexible dynamic data structure. Compiling a data structure defined and manipulated as the program runs, in response to it running, is impossible. Try writing the compiler that can do this: s = append(s, s[v] & s[j..floor(length(s)/2) + x] ) or something even more abstract. --- Sincerely, Mathew Hounsell Mat.Hounsell at mailexcite.com Free web-based email, Forever, From anywhere! http://www.mailexcite.com