in addition to this I am able to open a windows folder by running Url: c:/folder name but I would like to open a folder that is based on the current record. e.g
I have a folder for each record in the database and each folder starts with a letter and a number e.g: G22303 the letter is pretty standard but the number will be record dependant, so i would like to click a button and it open the folder relevent to the record that is open, how would i script this?
at the moment I "open url" and i have this specified as: "C:\G22303" but i want the number to be linked to the record can this be done like this:
$= "record number"
or something similer?
or even "C:\G" & Yourtable::RecordNumberField, used as a calculation inside the Open URL step.
thats perfect, I was trying to do it all inside the quotes! this is why i had issues.
Am I amble to run MS DOS batch files like this? i.e:
"C:\G" & Yourtable::RecordNumberField "run.bat"
and how would I create a folder "G2203" in windows by pushing a button with a script.
I'd be inclined to investigate one of the third part plug ins that can manipulate folders and files. One, MooPlug, may be able to do this and it was free the last time I checked.
I believe it's possible to run a batch file, but haven't done so and am unsure if I remember correctly how to set it up. I seem to recall there was a way to use send event to do this. As I recall, you can build the batch file text in a text field (that way you can incorporate the folder name you want), use export field contents to create the text file, then use send event to actually run the batch file.
thanks Phil, I have dowloaded the mooplu i will have a play, this is the first time i used a plugin so it should be fun. I had a play with the sample file so i think it will be ok.
I do not add plugins into a solution lightly because it increases complexity of a system ... there are maintenance issues involved: installing plugin on user systems, updating whenever plugin or FM updates, testing that the two are compatible before releasing into live production solution (which should be done BEFORE every OS update, FM update, plugin update). I know businesses that were even held up from upgrading to new version of FM because a major plugin used within it was not yet compatible with the new FM version. One business desperately needed to purchase additional copies of FM for new Users but the prior version was no longer available to purchase and the new version could not run the plugin. They had to wait three months before they could add new seats. This can really hurt a business. So when possible, do it natively using FM. And if not possible, establish strict protocol and document upgrading procedures.
And in this case, you can use Send Event to run your DOS batches - I do it all the time. You can also use VBScript to gather names of files in a folder if you need it so you can import the data from all the files within the folder. It can get complex (working at the command line) if the solution needs to be cross-compatible because Windows uses back slashes whereas Mac uses forward slashes in pathing. But once you understand the xplat differences and once it is scripted, it is rock solid. Neither platform will change the behavior of primary OS-level commands. Your DOS batch can actually be handled within Send Event also so that you do not need to put the DOS batch on anyone's system, similar to:
Text: cmd /c md C:\NewFolder
I can not say which is best for you, Fluffy. But I want to be sure you and others are aware that these possibilities exist and are scripted into solutions by Developers and used by businesses every day.
I totally agree on your points, and your code works a treat! thankyou.
I now need to work out if it is possible to view the contents of a folder within a form.
The answer is probably yes but it depends upon 1) what you want to see in the folder (whether you want to see all the clutter or just the file names, or whether you need sub-folders etc) and 2) what you plan to do with that information. You can grab it and set a global text field with it (for simple viewing) or you can import any file names in a folder into a table as records.
Can you explain the purpose and the context?
I am not fully sure what I want to do at this point as when you start playing with these things all sorts of ideas start happening when the possiblities arise!
Initially I would just want a snapshot of what is in the folder so that I will know if certain files have been created or not. so it will show some other folders and variouse files. I think this can be done with a web viewer which is what I am currently playing with.
however it would be good to be able to run the files and create new ones etc.. from the layout by clicking on them in the folder view, but I relise that this can be done with my batch file process that i initially asked about.
basically with each main record there is always a set of files and folders and I am going to set up a form that gives some control and viewing of these.
"Initially I would just want a snapshot of what is in the folder so that I will know if certain files have been created or not."
So a human will know? Or so that a computer will know? If you produce a simple reproduction of the folder as regular text, neither a User or the system will be able to easily 'select' one line for process. It is best to produce a clean list of files which, when selected, can run scripts based upon that file name. Web viewer will not provide functionality because the 'view' cannot be used in any way. If you want the entire folder, DOS could be used thus: dir > list.txt
> in DOS is 'redirect' and not 'greater than' and this creates a text file with everything you see when you issue DIR at a prompt. Then import list.txt and delete it again when done or you can store it in the windows temp directory and leave it.
If you want a clean list of files only, you can use VBScript (or parse and strip list.txt before displaying; it just takes a bit more work). Well, here is a link to a file I created for a gal who did not want to use plugins and the list of files only needed to be grabbed so that each file, depending upon file type, could be imported with the proper import script without hard-coding. The OS level can be used to produce a 'hopper' where any files landing in that folder are processed and files, once import is successful, can be moved to another folder.
As you import these file names into a table, set the validation on the file name to unique (field definitions). In this way, if someone places same file again in that folder, it will not import. I've written several of these types of solutions for processing incoming data and you might find the discussion and file helpful here. http://fmforums.com/forum/topic/80339-wildcard-in-file-name/page__fromsearch__1
If you do this, I suggest you lean towards producing a clean list of files as records into a table (whether for viewing by User, selecting by User, or running script based upon file type or patterns within the file name). It will be the easiest than designing only for 'user viewing' as a text field only to later change the whole thing and it takes about same amount of effort. The table itself would only have a few fields so it is not a burden on a solution. Also, if files are incoming and named default-consistent then performing scripts upon them based upon patterns in their names will provide further automation and simplicity.
So your folders can be dynamic, pulling their 'name' from a record, such as G22303 and your files can be dynamic ... scripting different imports depending on data type; csv, excel and depending upon strings within the file name itself. You can also then FIND on patterns so if files are named consistently, you can search for *22303* to get list of that customer's directories, for example ... or find a folder easily and view all files within it ... clicking on file to open it. All cool stuff. :^)
I have managed to create the txt file and need to look a bit deeper to import the data, at this stage I need a simple view of the folder contents as oposed to the data. is it possible to just import this text file into a field just to view it as a list?
also when using the web viewer I can list the contents of the folder ok, and i can double click on the icons to actualy launch the files if required, however the viewer is only showing the files as large icons, I can't see a way to change the view to a list view or to reduce the icones etc.. do you know of a way to change how the web viewer shows the files?
"is it possible to just import this text file into a field just to view it as a list?"
Once you have created the text file, create a global text field and import the text file into it for display anywhere you want it.
Web viewer will be very limited. AFAIK, there is no way to make it display as a list instead of icon; maybe someone else knows a way. If you import the file names themselves, as suggested in importing the lines as records into an auxiliary table, you can still set it up to open the file upon selection of the file name. You have lots of options. :^)
Hi Larretta yes I agree this is somthing I am going to mess about with and learn. with regards to the importing of the txt file into a global field is this done by using: "import records" command?
Yes, you would import just like you regularly do only go to a layout based upon table occurrence where the global text field belongs. It does not have to be on the layout to import into it.
You can tell when you script the import step because it will show the entire file lining up on one row so just point it to the global.