Page 1 of 1

writing text to any file from inside AM

PostPosted: Thu Oct 15, 2009 3:47 am
by reneuend
I figured out how to write a text stream to any file you want in any format to a file from inside AM. No plugin needed.

Tutorial coming soon!

PostPosted: Thu Oct 15, 2009 2:22 pm
by Lyberodoggy
Great!!! I'd love to read that tutorial...

PostPosted: Thu Oct 15, 2009 3:04 pm
by ShadowHunter
Same here :D

PostPosted: Mon Oct 19, 2009 2:43 pm
by Kat12
Sounds interesting!
Kat

PostPosted: Mon Oct 19, 2009 5:08 pm
by reneuend
I haven't forgotten this....I've been busy beta-testing something that is going to really shake up the AM world! :D

PostPosted: Sat Jan 08, 2011 9:37 pm
by reneuend
OK..First, I know I posted how to do this somewhere in these forums a very long time ago, because I used this with my Throwman game. I'm confused! :shock:

I used it to save passwords, game stats and scores, and lines of text.

It is very very simple to use.
NOTE: I'm going to add a tutorial on this in issue 15 of bbb. :wink:


Code: Select all
Sub Write2File(yourfilename, byval savetext)

  dim myfile
  set filesys = CreateObject ("Scripting.FileSystemObject")
  set myfile = filesys.CreateTextFile (GetPath(2) & yourfilename, true)
  set myfile = filesys.GetFile(GetPath(2) & yourfilename)
  set txtstream = myfile.OpenAsTextStream (2, -2)
  txtstream.Write savetext
  txtstream.Close

End Sub



Code: Select all
Function GetAllFileContents(yourfilename)

  Dim mytext
  Dim myfile

  set filesys = CreateObject ("Scripting.FileSystemObject")
  set myfile = filesys.GetFile(GetPath(2) & yourfilename)
  set txtstream = myfile.OpenAsTextStream (1, -2)

  mytext = txtstream.readall()
  txtstream.Close

  GetAllFileContents = mytext

End Function

PostPosted: Sun Jan 09, 2011 11:03 pm
by Lyberodoggy
Great! works perfectly, thanks