When you get the white screen that you describe, there is some problem with the way you are trying to use the SDK components. Usually you are getting a NullObjectException.
There are two basic approaches you can use:
Simply comment all of you code and see if you can at least get your UI components to display, then successively uncomment the code until the white screen returns.
Wrap all of your code in a Try/Catch block and catch the exception, then display it in a GTPUMessageBox.
By looking at your code above, it appears that you are not instantiating the controller object. You might try:
I’ve been trying to acces files in the RC from FP SDK, but can’t seem to get it to work. So, now I have some questions:
does GetFilesAndDirectory only work in RemoteDirectory?
if so, how can I acces files outside the default directory?
how do I set RemoteDirectory to a directory I want? I tried theFiles.RemoteDirectory=“/hd0a/lasmod/” but get a nice crash (theFiles works correctly in getting RemoteDirectory string).
I have experienced problems using RemoteDirectory and LocalDirectory as you are, despite the fact that they are shown as read/write properties.
It is useful to treat these properties as though they were environment variables with the following values:
RemoteDirectory = HOME dir of the active system on RC flash disk
LocalDirectory = TEMP dir on the FlexPendant’s file system
You can use these values as a basis for forming a path to access files anywhere in the file system.
Using this information then, to access a file called “test.prg” in a folder called “Test” on the the root of /hd0a/, you can form the path in the following manner:
Dim strTestFile as String = “test.prg”
Dim ARemoteFile As String = ctrl.FileSystem.RemoteDirectory + “/../../Test/” + strTestFile
Once you have created a properly structured path in the form of a string, you can use this string as an argument to various methods in FileSystemDomain.
Note: the “/../” character sequence is used to move up one directory in the robot file system. Two instances of “/../”, i.e. “/../../” retrieves the root of hd0a from the HOME directory.
Itried your suggestions, and it works OK when loading RAPID modules, or getting/putting files. But when I want to test for the existence of a file, things don’t go so smoothly. I tried two options:
Dim fileInf As ControllerFileSystemInfo() = TheFiles.GetFilesAndDirectories(TheFiles.RemoteDirectory + “/../../” + “lasmod/*.mod”) and then test for the presence of any entries in fileInf. It remains empty.
If File.Exists(TheFiles.RemoteDirectory + “/../../” + “lasmod/<filename>.mod”) = True Then
this doesn’t work either, both when trying this path string as well as using /hd0a/lasmod/.mod. It always evaluates as false, whether the file exists or not.
So, my question is, what is the best way to test if a file exists?
Dim fileInf As ControllerFileSystemInfo() = TheFiles.GetFilesAndDirectories(TheFiles.RemoteDirectory + “/../../” + “lasmod/*.mod”) and then test for the presence of any entries in fileInf. It remains empty.
([/QUOTE]
Hi.
When calling GetFilesAndDirectories you should only input the filename, and not the entire path since that information already exists in the TheFiles.RemoteDirectory property.
Me too, I have to evaluate the existance of a file in the remote directory. As suggested by Alex Lu, I try to get a local copy of the file using:
GetFile(strRemoteFilePath, strLocalFilePath)
and then check the existance of the local file using:
System.IO.File.Exists(strLocalFilePath)
However, my application is having a pretty weird behaviour:
When strRemoteFilePath exists, everything goes fine; but when it doesn’t, the method from which I call GetFile() just returns without completing the rest of instructions, showing no error message or crashing or anything.
I’m kinda desperate. Can anyone help me? Maybe jan-jaap found a way to check file existance?
where RemoteDir is hd0alasmod. If the file doesn’t exist, there will be an error, which I handle in using:
On Error GoTo ErrGetFileFail
In the ErrGetFileFail part, I generate a GTPUmessagebox. This also works for the opposite: checking for file existance before overwriting the old file.
Hope you can use this info. If you have more problems, post your code.
I followed your advice and include the GetFile sentence in a try-catch block (I use C#). I use the exception as a sign of the non-existance of the file and now I have my application up-and running. Thanks!
In case this can help someone, what puzzled me most was the fact that, before I added the try-catch, the unhandled exception didn’t show up, and the method just returned at that point, without reaching the end. This happened because it was not a regular method, but a MessageBoxEventHandler and apparently in the Virtual Flexpendant the exceptions originated in these methods don’t raise up (however, I think they actually do in the Real Flexpendant, forcing you to restart it!).
The moral of the story: don’t forget to handle errors.