(No Subject)
- Posted by Mathew Hounsell <mat.hounsell at MAILEXCITE.COM> Apr 26, 1998
- 896 views
The following function returns the path to the code / exe file of your programs if you make sure all the program files are in specified directories relative to that file, you will always find them, no matter which directory you currently in. eg c:\apps\dos\makechar\makechar.exe get_program_path returns "c:\apps\dos\makechar\" It always returns a sequence. notice the \ on the end, thats to make concaternating easy. eg path & filename eg sequence path path = get_program_path() load_video(path & "video\start.fli") -----<snip>----- global function get_program_path() sequence cmd, val val = {} cmd = command_line() if length(cmd) >= 2 then for t = length(cmd) to 1 by -1 do if cmd[t] = '\\' then val = {cmd[1..t],cmd[t+1..length(s)]} exit end if end for end if return val[1] end function -----<end snip>----- David Mosley wrote > I can program in Liberty Basic I got really hooked on programming using LB. File Input Routines... I use getc instead of gets as it doesn't forget the last line if there is no EOL marker. (Dave: EE does lose last line.) -----<Untested Snip>----- function load_file(sequence fname) -- for a single dim sequence integer fn, char object val val = -1 -- default return fn = open(fname,"r") if fn != -1 then val = {} -- make val a sequence while 1 do -- loop forever (Maniacal Laughter) char = getc() -- gets a character from file if char = -1 then -- is it end_of _file exit -- if yes leave else val = val & char -- if not the add it too end of return sequence end if end while end if return val -- And the result was ... end function function load_file(sequence fname) -- for a double dim sequnece based on lines integer fn, char sequence line object val val = -1 -- default return fn = open(fname,"r") if fn != -1 then val = {} -- make val a sequence line = {} while 1 do -- loop forever (Maniacal Laughter) char = getc() -- gets a character from file if char = -1 then -- is it end_of _file exit -- if yes leave loo[ if length(line) then val = append(val,line) -- if it's not a blank line at end of file add it. end if elsif char = 10 or char = 13 then -- is it end of line val = append(val,line) -- add line, note doesn't add CR or LF (10 or 13) else line = line & char -- if not the add it too end of return sequence end if end while end if return val -- And the result was ... end function -----<end snip>----- Christopher D. Hickman responded to my post: >> type description( sequence s ) >> elements are integers >> length is 256 >> >> return 1 >> end type > What does this solve? ERR : Unexpected sequence found in character string. and similar errors. >> structure my_struct_type >> integer member1, >> atom member2, >> sequence member3, >> object member4 >> end structure as opposed to > complex menu_item ( sequence s) > format { menu_str, integer, string, integer } > return 1 > end complex A rose by any other name would smell as sweet... It is asthetics. You have a C background. There is one prob with structure, a novice to the language may think it is a C similar structure that could be passed to a DLL etc. > Structures in Euphoria aren't (or shouldn't be, I should say) about limiting anything, > but giving the programmer a tool to work with sequences at a more abstract level... > improving readability to allow faster implementation, better control, and less time > debugging. Type is used to restrict the data type is euphoria, if you've decided you need a sequence containg numbers and sequences you don't want the numbers being sequences, it would save debugging type, and may even help with binding optimization. Kasey Responded to everyone with... > This sounds like somthing a good preprocessor could do. In fact most of the changes > people want could probably be done with a preprocessor, which if customizeable, > could let them EACH have thier own personal flavor of Euphoria Dave has one, but nobody wants too write one, I might if nobody objected... > Anything... I want I'll find a way to do with Euporia <Whineey Kids Voice> But it's easier if ROB does it... </WKV> It's can also be faster and more efficient. Irv wrote > (On the other hand, what's the most used language?) > (Hint: it starts with 'C', and has a thousand bells and whistles) Well there's no accounting for taste. --- Sincerely, Mathew Hounsell Mat.Hounsell at mailexcite.com Ps I have a feeling the above line layout spacing got minced. Free web-based email, Forever, From anywhere! http://www.mailexcite.com