Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
saving files
#1
how do i take user input and save a file as that? just wondering
Reply
#2
you mean save the file with the file name being the inputed text? or with the data inside
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#3
save the file with the inputted text as the filename
Reply
#4
OPEN can take a string variable as the filename, like so:
Code:
OPEN f$ FOR OUTPUT AS #1
Reply
#5
Quote:save the file with the inputted text as the filename

Code:
INPUT a$
OPEN a$ FOR OUTPUT AS #1


tha opens the file wiith the inputed file name and if it doesn't exist then it makes one
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#6
thanks but thats not the exact answer i was looking for
here is an example

input a$
open "C:\a$.dat" for input as #1

i am trying to write a file to a specific location with the filename as the inputted text.

do you kind of see where i am going with this?
thanks
Reply
#7
It's basicly there. If you want to add the path and file extension, you need to do it a little differently
Code:
INPUT,"Enter the name of the file you want to open", FileName$

FileName$ = "C:\"+FileName$+".dat"
Open FileName$ for input as #1

'The two lines above could be combined: Open "C:\"+FileName$+".dat" for input as #1

        'code
        'code
        'code

Close #1
In either case, what happens if the user includes a path or extension in the file name? Is there something you could do to prevent problems?
hrist Jesus came into the world to save sinners, of whom I am first.(I Timothy 1:15)

For God so loved the world, that He gave His only begotten Son,
that whoever believes in Him should not perish, but have eternal life.(John 3:16)
Reply
#8
woah. that's cool, didn't know you could do that. spiffy. thanks.
Reply
#9
Code:
ON ERROR GOSUB carryon
IF MID$(filename$, LEN(filename$) - 4, 1) = "." THEN ' .xxx file xtn
  filename$ = LEFT$(filename$, LEN(filename$) - 4)
END IF

carryon:
' Open file
RETURN

I think that'll work, but I don't know all the rules around GOSUB... will that code, without an error, move into the carryon sub?
Reply
#10
thanks, i think i got it now
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)