File Names

Tom Christman

Active Member
Licensed User
Longtime User
Is there an easy way to automatically create a new file name (say for storing screen png) eg Pix1, Pix2, Pixn, etc so that a user will have a sequence of screens stored in separate files? Thanks
 

klaus

Expert
Licensed User
Longtime User
Create a global counter variable in Sub Process_Globals.
Dim Counter AsInt

Initialize it
Counter = 0

Increase it
Counter = Counter + 1

Create a variable for the filename:
Dim FileName AsString

Set it
FileName = "Pgn"&Counter

Best regards.
 
Upvote 0

Tom Christman

Active Member
Licensed User
Longtime User
Thank you so much Klaus for the fast reply. My old code for storage was:
Dim Out As OutputStream
Out = File.OpenOutput (File.DirRootExternal,"Test1.png",False)
can1.Bitmap.WriteToStream(out, 100, "PNG")
Out.Close

When I put your code in the counter loop :
counter = counter + 1
filename = (counter)
Dim Out As OutputStream
Out = File.OpenOutput( File.DirRootExternal,"Test"&filename&".png",False)
can1.Bitmap.WriteToStream(out, 100, "PNG")
Out.Close

It works beautifully (remembering to Dim the Test etc.) and the data is stored in Test1, Test2, ...sequentially.
Thanks Klaus so much for your time and expertise!
Tom
 
Upvote 0
Top