1. How to use file_num = open ( "file", "mode" )

I'm fairly new to programming, and would appreciate someone's advice on how
to write code to achieve this:
1   ask the user to:
    a)   nominate the drive on which to create a file - eg "C"
    b)   name the file to be created - eg "entries.dat"
2   create and open that file - "c:\entries.dat" - for output

I'm able to use....

     file_num = open ( "c:\\entries.dat", "w" )

               .... but only if I specify the details myself!

Thank you

Alex Caracatsanis

new topic     » topic index » view message » categorize

2. Re: How to use file_num = open ( "file", "mode" )

On Sat, 12 Aug 2000, Caracatsanis Pty Ltd wrote:
> I'm fairly new to programming, and would appreciate someone's advice on how
> to write code to achieve this:
> 1   ask the user to:
>     a)   nominate the drive on which to create a file - eg "C"
>     b)   name the file to be created - eg "entries.dat"
> 2   create and open that file - "c:\entries.dat" - for output
>
> I'm able to use....
>
>      file_num = open ( "c:\\entries.dat", "w" )
>
>                .... but only if I specify the details myself!
>
> Thank you
>
> Alex Caracatsanis

here try something like this:

-- untested code

include get.e

atom fn
sequence full_path, drive, file

puts(1, "enter drive letter: ")
drive = gets(0) -- get the drive letter in a sequence
puts(1, "enter file name: ")
file = gets(0) -- get the file name in a sequence

full_path = append( drive, ":\\") -- append the ":\\" to the end of the drive
full_path = append( full_path, file ) -- app the file name to the drive letter
                                      -- and ":\\"

fn = open( full_path, "w" )
   -- do your stuff
close(fn)


hope that helps ( or even works! )

--
cense
a member of the
ak-software development team
http://www.ak-software.com/

contract work for
Web Velocity IT inc.
http://www.webvelocity.ca/

new topic     » goto parent     » topic index » view message » categorize

3. Re: How to use file_num = open ( "file", "mode" )

cense just wrote:

>here try something like this:
>
>-- untested code
>
>include get.e
>
>atom fn
>sequence full_path, drive, file
>
>puts(1, "enter drive letter: ")
>drive = gets(0) -- get the drive letter in a sequence
>puts(1, "enter file name: ")
>file = gets(0) -- get the file name in a sequence
>
>full_path = append( drive, ":\\") -- append the ":\\" to the end of
the drive
>full_path = append( full_path, file ) -- app the file name to the
drive letter
>                                      -- and ":\\"
>
>fn = open( full_path, "w" )
>   -- do your stuff
>close(fn)
>
>hope that helps ( or even works! )
>
>--
>cense


No, it does not help, because it does not work!
It takes only about 30 seconds to test it, if it works.
If it does not, it usually takes a bit longer, but it saves you a lot
of embarrassment and you do not confuse the poor newbie even more.

jiri


include get.e

atom fn
sequence full_path, drive, file

puts(1, "Enter drive letter: ")
drive = gets(0)                     -- get the drive letter in a
sequence
drive = drive[1..1]                 -- strip newline

puts(1, "\nEnter file name: ")
file = gets(0)                      -- get the file name in a sequence
file = file[1..length(file)-1]      -- strip newline

full_path = drive & ":\\" & file    -- concatenate

fn = open( full_path, "w" )
    -- do your stuff
close(fn)

new topic     » goto parent     » topic index » view message » categorize

4. Re: How to use file_num = open ( "file", "mode" )

On Sat, 12 Aug 2000, jiri babor wrote:
> cense just wrote:
>
> >here try something like this:
> >
> >-- untested code
> >
> >include get.e
> >
> >atom fn
> >sequence full_path, drive, file
> >
> >puts(1, "enter drive letter: ")
> >drive = gets(0) -- get the drive letter in a sequence
> >puts(1, "enter file name: ")
> >file = gets(0) -- get the file name in a sequence
> >
> >full_path = append( drive, ":\\") -- append the ":\\" to the end of
> the drive
> >full_path = append( full_path, file ) -- app the file name to the
> drive letter
> >                                      -- and ":\\"
> >
> >fn = open( full_path, "w" )
> >   -- do your stuff
> >close(fn)
> >
> >hope that helps ( or even works! )
> >
> >--
> >cense
>
>
> No, it does not help, because it does not work!
> It takes only about 30 seconds to test it, if it works.
> If it does not, it usually takes a bit longer, but it saves you a lot
> of embarrassment and you do not confuse the poor newbie even more.
>
> jiri
>

hey jiri, its no embarassment. At least i was truthful about it not knowing if
it worked. sorry for not testing it and all ( i know you *HATE* untested code
posters ) but i am running linux at the moments and i still have not bothered
to setup euphoria for linux very well yet.

>
> include get.e
>
> atom fn
> sequence full_path, drive, file
>
> puts(1, "Enter drive letter: ")
> drive = gets(0)                     -- get the drive letter in a
> sequence
> drive = drive[1..1]                 -- strip newline
>
> puts(1, "\nEnter file name: ")
> file = gets(0)                      -- get the file name in a sequence
> file = file[1..length(file)-1]      -- strip newline
>
> full_path = drive & ":\\" & file    -- concatenate
>
> fn = open( full_path, "w" )
>     -- do your stuff
> close(fn)

good work on fixing my crap for code jiri. It been a while since i actually
finnished a project in euphoria. sorry Mr newbie that i confused

--
cense
a member of the
ak-software development team
http://www.ak-software.com/

contract work for
Web Velocity IT inc.
http://www.webvelocity.ca/

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu