09-10-2003, 01:22 AM
Pages: 1 2
09-10-2003, 01:25 AM
you mean save the file with the file name being the inputed text? or with the data inside
09-10-2003, 01:46 AM
save the file with the inputted text as the filename
09-10-2003, 01:52 AM
OPEN can take a string variable as the filename, like so:
Code:
OPEN f$ FOR OUTPUT AS #1
09-10-2003, 01:52 AM
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
09-10-2003, 04:25 AM
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
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
09-10-2003, 04:57 AM
It's basicly there. If you want to add the path and file extension, you need to do it a little differentlyIn 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?
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
09-10-2003, 05:03 AM
woah. that's cool, didn't know you could do that. spiffy. thanks.
09-10-2003, 05:14 AM
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?
09-10-2003, 06:13 AM
thanks, i think i got it now
Pages: 1 2