Author Topic: Launch File Dialog to save a file  (Read 13851 times)

AnonymousPostings

  • Newbie
  • *
  • Posts: 49
Launch File Dialog to save a file
« on: July 01, 2010, 10:34:37 AM »
Hello, I wonder if you could help me.
I'm trying to make my program launch a file dialog box when a button is clicked on that asks the user to choose a location to save a file in and then allow them to save the file in that location.
 
This maybe a small task, but I'm unable to work this one out, and I would really appreciate some help! I assume it would be "FileNew" but the explanation in the "Language Reference" PDF is different to the in-software "Overview".
« Last Edit: January 01, 1970, 01:00:00 AM by Guest »

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 464
  • Here to help you
Re: Launch File Dialog to save a file
« Reply #1 on: July 01, 2010, 10:38:38 AM »
I'm sorry about the documentation it does really need improving.


There are two stages to creating your user requested file.

1) The user is asked the location and name of the file - this returns a file handle you can actually use to create and write to the file.

Code: [Select]
Local fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens

FileNew(fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens)

Note, there are a lot of parameters in the above command but you can ignore most of them unless you need detailed information about the file, path, extension etc.



2) Create the file using the returned parameters. This is the same for both binary and text files - they both use the returned file handle. Here is a binary example.

Code: [Select]
Local findex,n

CreateBFile(fhandle,findex)
WriteBVariable(findex,'hello')
For n=1 to 10
    WriteBByte(findex,n)
EndFor
CloseBFile(findex)
« Last Edit: January 01, 1970, 01:00:00 AM by Guest »
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

tools-n-stuff

  • Newbie
  • *
  • Posts: 38
Re: Launch File Dialog to save a file
« Reply #2 on: October 28, 2010, 12:27:36 PM »
Quote from: "Malkom"
I'm sorry about the documentation it does really need improving.


There are two stages to creating your user requested file.

1) The user is asked the location and name of the file - this returns a file handle you can actually use to create and write to the file.

Code: [Select]
Local fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens

FileNew(fname,fhandle,fdetails,ctypes,cpaths,cnames,fextens)

Note, there are a lot of parameters in the above command but you can ignore most of them unless you need detailed information about the file, path, extension etc.



2) Create the file using the returned parameters. This is the same for both binary and text files - they both use the returned file handle. Here is a binary example.

Code: [Select]
Local findex,n

CreateBFile(fhandle,findex)
WriteBVariable(findex,'hello')
For n=1 to 10
    WriteBByte(findex,n)
EndFor
CloseBFile(findex)


The thing i am missing here is the file! I can't see what its supposed to write too. From looking at it i get the impression that it is creatingBFile and then writing 'hello' to it. I just can't understand where its writing to, i'm missing a step in the logic somewhere,  :x

As well as that i don't understand where the code should be placed.

From the initial post the visitor asked for a dialog pop, but i need it to read on start-up and write on quitting, and silently to a pre-created file. Would i have to create a file first and place it in the data file folder and call on it's name and extension?
 Iv'e looked at the examples, maybe missed one, but can't see one that has a working example.

Its really confusing  :?
« Last Edit: January 01, 1970, 01:00:00 AM by Guest »

Malkom

  • Administrator
  • Newbie
  • *****
  • Posts: 464
  • Here to help you
Re: Launch File Dialog to save a file
« Reply #3 on: October 28, 2010, 09:32:37 PM »
The local variable fname holds the name and path to the file.

You can see it declared in the Excel binary file post:-

  http://http://www.tigabyte.com/forums/viewtopic.php?f=22&t=14

Code: [Select]
@ File name
Put 'test1.csv' into fname

I hope this helps.
« Last Edit: January 01, 1970, 01:00:00 AM by Guest »
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

mihir

  • Newbie
  • *
  • Posts: 3
Re: Launch File Dialog to save a file
« Reply #4 on: December 31, 2011, 04:11:35 AM »
i tried the codes posted by malkom.......thanks for it!!

But,the file doesnt save on desktop........a dialog box to save the same appears,but it doesnt get saved...
please help!!