Author Topic: How to find a file on the hard drive  (Read 2872 times)

bevthompson

  • Newbie
  • *
  • Posts: 2
How to find a file on the hard drive
« on: October 12, 2012, 11:33:24 AM »
I have just come across Hypernext and I am trying it out all is ok at the moment but I am trying to find a  way of finding a file to open on the harddrive. This would be the equivalent of "openfiledialogue" in Visual Basic, also is there an equivalent to "savefiledialogue"?

tigabyte

  • Administrator
  • Newbie
  • *****
  • Posts: 54
Re: How to find a file on the hard drive
« Reply #1 on: October 13, 2012, 06:40:21 AM »
I have just come across Hypernext and I am trying it out all is ok at the moment but I am trying to find a  way of finding a file to open on the harddrive. This would be the equivalent of "openfiledialogue" in Visual Basic, also is there an equivalent to "savefiledialogue"?

Hello

Yes, there are a few commands for opening and saving files via a dialogue box. They are listed in Chapter 15 of the Language Reference PDF.

Note, all the commands return a file handle that can be used to actually read from the file or write to it.
They also return the file name, and for opening they also return a file details list that shows info about the file.


(1) For opening a file there is the FileAsk and FileAskFilter commands

FileAsk:-
Presents a dialog box allowing the user to choose a file which already exists.

FileAsk(fname,fhandle,fdetails)


FileAskFilter:-
Presents a dialog box allowing the user to choose a file which already exists and has the specified file type. If the filter parameter is empty then all files are shown.

FileAskFilter(fname,filter,fhandle,fdetails)

Eg, filter might be = ‘HNapp’ etc



(2) For saving a file via a dialogue box

FileNew:-
Presents a dialog box allowing the user to choose the name and location of where a new file should be placed. This does not create the file but returns a handle and details about the potential file.

FileNew(fname,fhandle,fdetails)


I hope this makes sense compared to VB.

Malkom

bevthompson

  • Newbie
  • *
  • Posts: 2
Re: How to find a file on the hard drive
« Reply #2 on: October 13, 2012, 04:09:05 PM »
Thank you for your reply. I do not think my question was well worded- I really want to be able to view a directory of contents of the hard drive and then choose the file I want
Regards
Bev

tigabyte

  • Administrator
  • Newbie
  • *****
  • Posts: 54
Re: How to find a file on the hard drive
« Reply #3 on: October 15, 2012, 05:54:33 AM »
Thank you for your reply. I do not think my question was well worded- I really want to be able to view a directory of contents of the hard drive and then choose the file I want
Regards
Bev

Yes you can get a list of all files and folders but it will require a bit of coding.
Again, the functions and commands are in chapter 15 of Language Reference PDF.

First - use the functions VolumeCountFN and VolumeListFN to find how many and the names of the volumes.

Second - using the FolderItemGetAbs command to return details about each folder/file and then look at their details - if a file then just list it - if a folder then use its folder handle to get the details of its contents.

something like below should help you get started, where field 1 is a single line field and field 2 is a multiline scrolling field:-

Code: [Select]
Local vcount,vlist,root

Put VolumeCountFN into vcount
Put vcount into field 1

Put VolumeListFN into vlist
Put vlist into field 2



@ ---- Get root details
Put line 1 of vlist into root

local fname,fhandle,fdetails,ftypes,fpaths,fnames,fextens

Put root into fname
FolderItemGetAbs( fname,fhandle,fdetails,ftypes,fpaths,fnames,fextens)

Put fpaths after field 2


You will need to extend this to look into each folder etc.

Malkom