Sorry to be such a nag but I really want to help make Servoy fly like an eagle.
I want to use the file plug-in to get a list of files and folders in a directory. I tested the getFolderContents function of the file plug-in as follows:
var TheDeskTopFolder = plugins.file.getDesktopFolder();
mytextfield1 = TheDeskTopFolder
var ListOfFilesAndFolders = plugins.file.getFolderContents(TheDeskTopFolder)
mytextfield2 =ListOfFilesAndFolders
mytextfield1 contains the path to my desktop folder
Sorry to be such a nag but I really want to help make Servoy fly like an eagle.
That’s OK. THis is what the forum is ment for.
plugins.file.getFolderContents(TheDeskTopFolder) returns an array.
That’s why you see [Lcom.servoy.r2.plugins.file.JSFile;@fd9d27 inside your field mytextfield2
Here’s the correct syntax
var deskTopContent = plugins.file.getDesktopFolder()
var contentArray = plugins.file.getFolderContents( deskTopContent)
var fileList = “” ;
for(i=0 ; i<contentArray.length ; i++)
{
fileList = fileList + contentArray*+“\n”* } If you hoover over the functions inside the method editor , a tooltip text will appaer that tells you what is returned examples: -deleteRecord >>void (means nothing is returned.) -plugins.file.getFolderContents( ) >> JSFile[] (array) -plugins.file.getModificationDate() >> Date -plugins.file.deleteFolder() >> Boolean also take a look at these links. They contain a wealth of information about java script. http://devedge.netscape.com/library/man … 1.5/guide/ http://devedge.netscape.com/library/man … reference/
Thanks for the explanation. As always, the answer is obvious once you know the answer. Your tips are great and I’ll check out the links. I am a pretty poor man when it comes to Java Script but I hope I can get the ‘wealth of knowledge’ you mentioned.
Hi - trying to use the file plugin. Could you pls tell me where can I go to read about each of the functions in this plugin? When I hover or click on the functions in the “JSFile” menu very little information is given. Move sample code also provides no info.
For example, how do I use mkdir to make a directory? How do I use lastModified?
of course that doesn’t work. like i said. You can only call JSFile methods like lastModified on JSFile objects (and those are returned by the file plugin)
So getting the last mofified date must be called this way (2.0b6)
var date = plugins.file.convertStringToJSFile(‘c:/test’).lastModified()
because (and this is point 2) “c:/test.txt” if just a String object (you can call indexOf or split functions on that thing) but to do file operations you have to convect that string to a JSFile object and that you do with the method above.
So a JSFile object is a representation of a file on disk.
3> always use / never \ (because that one wil be seen as a tab char or something very often)
what a JSFile is. What is a “representation of a file on disk” ? How is it different from the actual file? Does it grab the text in the file?
how to use the lastModified function. you seem to be saying you can’t use that function, but in the earlier post you seem to have said you can: “lastModified() will return a date so you can compare it with another date to let you know if it did change after that.”
“c:/temp” is not a a file?? But just a string that represents a filename??
so on “c:/temp” you can’t call lastModified() because it is a string object not a JSFile
i didn’t say it completely right what a jsfile was. a jsfile is object that points to a file on disk. So it is not a string object (with functions like substring/split) but another kind of object with it’s own set of functions (like lastModified and exists)
and you can use lastModified.. i typed an example how to use it, for this example you have to have 2.0b6:
var date = plugins.file.convertStringToJSFile(‘c:/test’).lastModified()
then you have the last modified date in the variable date of the file c:/test
OK, I’m just not getting this. I’m new to Java. If I need to read something to catch up to what you’re saying please tell me (I have the links to the vast java resources, but I can’t go read it all before I use this).
When you say:
"i didn’t say it completely right what a jsfile was. a jsfile is object that points to a file on disk. So it is not a string object (with functions like substring/split) but another kind of object with it’s own set of functions (like lastModified and exists) "
It’s pretty much a foreign language to me. Is there any way you can be more clear?
I don’t want to offend you but you have to breathe in some basic knowledge here…
I would say that looking close into the Servoy docs and picking up some general info on javascript would help you a lot. I would use some hours for this you will see that the Servoy/Java scripting becomes one of the languages you understand instead of seeing it as abracadabra.
You just have to do some reading. Unless you are a monkey-see-monkey-do then you just do it to learn.
It will make your Servoy life a ‘and they lived happily ever after…’ life!
Hi,
Completely agree, as a newbie I’m reading through JavaScript tutorials etc. in my spare time and am looking forward to the moment when it all gels.
I’m just trying to convince a client to go with Servoy rather than FM, and to let me move the dev timeframe we agreed to back, and a key issue is file manipulation. Unfortunately I’m not having luck finding documentation that’s leading me out of dark on this one so I’m not able to really make a promise to the client - although I’m making a lot of progress in most other areas.
If a base level of knowledge is best before asking more quesions about the file tools i’ll certainly be trying to get myself there.
create simple report template system for remote office staff who connect through a VPN. They’ll create templates in WORD and EXCEL in a folder on their office shared drive and will run a method that stores a file reference for each template in a servoy database and diplays each reference in a portal. Any user will be able to click on a reference which will run a method that must export the data to c:\merge\merge.mer [I UNDERSTAND THIS IS COMING OUT SOON?] and then open the document up through their VPN which will be already configured to connect to the merge.mer datasource.
I have this in FM and it’s a great way to let users make their own simple list reports or record macros in Excel to take a data set and turn it into a chart without having to learn anything new
I also have a couple of clients I’m considering migrating to Servoy who regularly get CSV files sent to them through many different pathways and I need them to be able to check if they’re in a particular folder, move them, and import them into their database (e.g., donations made to the organization online)
All of this is done through the troi file plugin in FM. I’m really glad Servoy has developed many of the functions of this plugin, I’m just not yet able to digest the documentation. But I know you can’t do it all at once and I’ll try to get myself as prepared as possible. Thank you!
Recently, I am using the Servoy file plug-in. I am used to using the Troi file plug-in for Filemaker (also written by some smart guys in Holland). A couple of observations for the members with a similar background:
It is great to be able to store the files in the database as apposed to in a directory that is manipulated by the Troi plug-in. Easier to backup, easier to maintain, easier to support. way way less code.
I had trouble using the plug-in at first because of the way it uses the power of JavaScript objects and array variables. After breaking down and reading about 50 pages out of a text book about JavaScript variables it began to make sense.
I love this plug-in and can do stuff with it much easier and with much less code than it took with my old FMP solution. I have worked with Filemaker from version 2.0 to 6.0(=4.1). I have only used Servoy for a few months and my Servoy solutions are already way better. More solid, more professional looking, way, way more scalable.
Thanks to the Servoy Team for making this file plug-in available. The Servoy team has added more functions to Servoy in the last 3 months than one 100 million dollar a year company has in the last 3 years. Keep it up.