curly
Full Member
Posts: 161
|
Post by curly on Jan 18, 2021 8:36:21 GMT -5
Hi guys, me again, is it possible to use existing windows routines for saving files, and navigating to other directories to find and open files?
|
|
|
Post by tsh73 on Jan 18, 2021 8:46:13 GMT -5
>>navigating to other directories If you mean manually, then FILEDIALOG - read the help file
There is LOADBMP and BMPSAVE for loading/saving bitmap files.
There is a trick to load text file in texteditor - look into TEXTEDITOR
All other Saving and opening file is up to you - there is OPEN FOR INPUT (allowing to read) and OPEN FOR OUTPUT (which will overwrite old file) But what you will no after you open files if entirely up to you. If you will not code reading/writing, it will not got loaded/saved.
|
|
curly
Full Member
Posts: 161
|
Post by curly on Jan 19, 2021 11:06:24 GMT -5
I'm not sure which way to go - my programme will store information about dwellings. All the files can be stored in one location if I can find a file quickly - some files will be stored as an address, some as postcodes (Zip codes?) and some with a unique 12 charater string. Might I be able to search all the files in a single directory for s group of charaters amongst the filenames, e.g. filename 278 Smith Street.txt, and just search for either 278 or smith, and return all those that match without looking through all the filenames?
|
|
|
Post by Brandon Parker on Jan 19, 2021 13:11:09 GMT -5
You most certainly can do that, but you have to iterate through the array associated with the Files command no matter what! Here is a short example...
You can take this example and expand upon it making yourself a nice subroutine/function fairly easily.
Make sure to change the filePath$ (no trailing "\" required) and searchFor$ variables to what you need for testing...
Global False : False = 0 Global True : True = 1
Dim Info$(0, 0)
'This will return whether a file exists with "278" in the name 'The value returned is the number of files that exist with the string 'in the name
'"Your File Path Here" filePath$ = "Your File Path Here"
'What you want to search for here searchFor$ = "278"
'reDimOnExit must be False to be able to use the Info$() array afterwards 'I like to provide the option to clean up things if I'm just checking 'whether a file simply exists and I subsequently do not require the Info$() 'array to be populated numFiles = fileExists(filePath$, "*";searchFor$;"*", False)
'Show the number of files in the directory containing "278" Print "Found ";numFiles;" file(s) with that string in the name."
Print
'If we have at least one file containing "278" in the name then 'loop through the files and print their full path & name If numFiles Then For i = 1 To numFiles Print filePath$ + "\" + Info$(i, 0) Next i End If End
Function fileExists(path$, filename$, reDimOnExit) Files path$, filename$, Info$() fileExists = Val(Info$(0, 0)) If reDimOnExit Then ReDim Info$(0, 0) End Function
{:0)
Brandon Parker
|
|
|
Post by Rod on Jan 19, 2021 14:01:43 GMT -5
To keep things simple and accessible just have one dwellings file with all the fields you need populated or not. Then it is one file to load into your array and then you can simply select records by matching whatever data you like.
If you look at the listbox search routine I posted recently you will see that it is selecting out records that match the search fragment and then listing found records in the listbox. So thats kinda what you are talking about.
|
|