[Gambas-user] notal noob: creating a file

bill billsanders at ...916...
Fri Mar 18 09:34:53 CET 2005


Hi there!  I'm just picking up gambas for the first time.  I'm starting with a 
basic little app, but I've run into my first snag.  I also can't quite seem 
to find any help in the tutorials or docs to answer this question.

The snippet is supposed to create a file, with a timestamp as the filename.

here's the relevant code:
----------
  DIM File_Post AS File
  DIM file_name AS String
  DIM arystrDate AS String[]
  DIM arystrTime AS String[]
  
  'get date in YYYY-MM-DD format
  arystrDate = Split(Date.Text, "/")
  file_name = arystrDate[2] & "-" & arystrDate[0] & "-" & arystrDate[1]

  'get time in HH-mm-SS format
  arystrTime = Split(Time.Text, ":")
    file_name = file_name & "_" & arystrTime[0] & "-" & arystrTime[1] & "-" & 
arystrTime[2]
  
  ' for sanity, lets see if the filename matches what I think it should be
  lblFileName.Text = file_name
----------

what do I put next though?  

I've tried:
OPEN file_name FOR CREATE AS #File_Post

but that gives me a "file does not exist error".  Which I thought CREATE would 
take care of.

Then I figured I'd throw a "WRITE" in there, after the CREATE, but that just 
gives me a syntax error.  I considered just using "touch" from within the 
program to create the file, but that seems silly.

Also, in some tutorials, I see the file reference with a # in front of it, and 
sometimes not.  What's that all about?

Any help is appreciated!
Bill Sanders




More information about the User mailing list