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

new topic     » goto parent     » topic index » view thread      » older message » newer message

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 thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu