In this tutorial we will create a basic file manager application. The file manager will consist of two NeoFM/FTP File Browsers and a button bar. When complete you will be able to use this application to manage files on your computer.

Getting Started

We recommend that you start with a new VisualNEO Win publication.


1. Begin by using VisualNEO Win's Rectangle tool to define the location on the screen where you want the two NeoFM/FTP File Browsers to appear. To do this, select the Rectangle tool from VisualNEO Win's Tool Palette and draw a large box on the left side of your publication's workspace. Select the Rectangle tool again and draw another box on the right side of your workspace. When your publication runs, the rectangles will be replaced by File Browsers.


If needed, adjust the size of the Rectangle objects so that each takes up about 1/2 of the publication's workspace. Your screen should now look like this:



2. We want the file manager to be resizable, so we need to set the Snap Position property of each rectangle. To do this place the mouse pointer over the rectangle on the left side of the workspace and click the right mouse button. This will display the rectangle's properties screen. Select Left Side from the Snap Position combo box and click OK.



3. Place the mouse pointer over the rectangle on the right side of the workspace, and click the right mouse button to display its properties screen. Select Center from the Snap Position combo box and click OK.


4. Next, let's add a splitter control that we can use to adjust the width of the two File Browsers while our file manager is running.


Select the Simple Text tool from VisualNEO Win's Tool Palette. Using this tool, draw a long thin box onto your publication's workspace. The position and height of the box are not critical at this point, but the box's width should be between five and ten pixels. Once the rectangle is approximately the correct width, release the mouse button.


The Text Properties screen will appear.


5. Set the Snap Position property to Left Side. Leave the Text object's caption blank.


6. Click on the Drag & Drop icon.



7. Set the Drag & Drop Mode property to Manual.


8. Click the Actions icon.



9. Click the Drag Drop tab at the bottom of the Action editor.



10. Copy and paste the following script into the Action editor:


If "[DropX]" "<" "30"

  SetVar "[DropX]" "30"

EndIf

If "[DropX]" ">" "[PubWidth]-30"

  SetVar "[DropX]" "[PubWidth]-30"

EndIf

SizeObject "Rectangle1" "[DropX]" "0"


Note: If the first Rectangle object you created in step 1 has a name other than "Rectangle1" then substitute that name above.


11. Click OK to save the changes.


Note: The text object should appear in between the two rectangles. If, for some reason, the text object appears to the left of the first rectangle, then grab it with your mouse and drag it toward the right side of the workspace.


12. When our application first starts we need to open two connections to the local file systems and display two File Browsers. A good place to put initialization stuff like this is in the publication's StartUp script. To access the StartUp script, select Book Properties > Actions from VisualNEO Win's Book menu.



The Book Properties screen will appear with the empty StartUp script displayed.


13. The first thing we want to do is add an action to make the first local file system connection. To do this click the Insert Action button in the upper right corner of the StartUp script editor.



14. Locate and select the NeoFM/FTP category among the icons on the left side of the Action Selector.



Note: If you don't see an icon for NeoFM/FTP, then you have not properly installed the plug-in. See Install Plug-Ins in VisualNEO Win's Options menu.


15. After selecting the NeoFM/FTP icon, select fmConnectLocal from the right side of the screen. The following dialog box will appear:



16. The first parameter is the Connection ID, which is simply a name that we will use to refer to this connection in the future. It can be anything you like, but it's often easiest to use something short and descriptive. We'll use this ID later for other commands.


For this tutorial, enter FileList1 for the Connection ID and C:\ for the Initial Path.


17. Click OK to add fmConnectLocal to the StartUp script.


18. Click the Insert Action button again and select the fmShowFileBrowser action.


19. Set the following fmShowFileBrowser action properties:


Connection ID:

FileList1

Rectangle object:

Rectangle1


Note: If the first Rectangle object you created in step 1 has a name other than "Rectangle1" then substitute that name above.


20. Click OK to add fmShowFileBrowser to the StartUp script.


21. Next, we need to add actions to make the second local file system connection. This will allow us to display two different folders at the same time and to drag  and drop files between them. As before, click the Insert Action button and select the fmConnectLocal action.


22. For the second connection, enter FileList2 for the Connection ID and C:\ for the Initial Path.


Note: It is important that the IDs for the two connections be different.


23. Click OK to add fmConnectLocal to the StartUp script.


24. Click the Insert Action button once more and select the fmShowFileBrowser action.


25. Set the following fmShowFileBrowser action properties:


Connection ID:

FileList2

Rectangle object:

Rectangle2


Note: If the second Rectangle object you created in step 1 has a name other than "Rectangle2" then substitute that name above. It's important that the two File Browsers be assigned to different Rectangles or the application will not function properly.


26. Click OK to add fmShowFileBrowser to the StartUp script.


27. Your screen should now look like this:



28. Click the OK button at the bottom of the Book Properties screen to save the StartUp script.


29. Our application needs a button bar, so select the Container tool from VisualNEO Win's Tool Palette. Using this tool, draw a box onto your publication's workspace. The position and width of the box are not critical, but the box's height should be about 32 pixels. Once the rectangle is approximately the correct height, release the mouse button.


30. Place the mouse pointer over the newly created Container, and click the right mouse button to display its properties screen. Select Top from the Snap Position combo box and click OK.


Your screen should now look something like this:



31. Next, select the Push Button tool from VisualNEO Win's Tool Palette. Place the mouse pointer over the top of the Container object you created in the previous step, and draw a small box. (We want the Button to be attached to the Container, so it's important that you begin drawing the box with the mouse pointer on top of the Container.) When you release the mouse button, the Push Button properties screen will appear.


32. Type Recycle in the button's Caption field.


33. Click the Actions icon.



34. Click the Insert Action button and select the fmRecycleSelected action.


35. Set the following fmRecycleSelected action properties:


Connection ID:

[FMFTP.ActiveClient]

Get Confirmation:

Yes

Show Progress:

Yes


Notice that we're using the variable [FMFTP.ActiveClient] instead of a specific Connection ID. This variable always contains the ID of the File Browser considered to be "active". This allows us to direct the recycle command to whichever File Browser is active at the time the Push Button is pressed. This is important since our application contains multiple File Browsers.


36. Click OK to save the changes to the Push Button.


If needed, adjust the size and position of the Push Button so that it is visible within the Container.


37. Next we need to add a special subroutine to our application. The purpose of this subroutine is to enable or disable the recycle button we added in the previous steps. Ideally, we only want the recycle button to be enabled when the active file browser contains one or more selected files. This will prevent users of our application from clicking the recycle button when it's not appropriate. (General information about subroutines can be found in your VisualNEO Win help file.)


To access the subroutine script, select Book Properties > Actions from VisualNEO Win's Book menu.


38. Click the Subroutines tab at the bottom of the Action editor.


39. Copy and paste the following script into the Action editor:


:FMFTP_FocusChanged

:FileList1_SelectionChanged

:FileList2_SelectionChanged

If "[[FMFTP.ActiveClient].SelCount]" ">" "0"

  EnableObject "PushButton1"

Else

  DisableObject "PushButton1"

EndIf

Return


Note: If the Push Button object you created has a name other than "PushButton1" then substitute that name above.


Actually, this script contains three different subroutines all combined into a single block of code. This trick works because we want to execute the same actions for each subroutine. Combining them this way simply saves space. Of course, we could have entered the subroutines separately instead. For example, the following is also valid:


:FMFTP_FocusChanged

If "[[FMFTP.ActiveClient].SelCount]" ">" "0"

  EnableObject "PushButton1"

Else

  DisableObject "PushButton1"

EndIf

Return


:FileList1_SelectionChanged

If "[[FMFTP.ActiveClient].SelCount]" ">" "0"

  EnableObject "PushButton1"

Else

  DisableObject "PushButton1"

EndIf

Return


:FileList2_SelectionChanged

If "[[FMFTP.ActiveClient].SelCount]" ">" "0"

  EnableObject "PushButton1"

Else

  DisableObject "PushButton1"

EndIf

Return


NeoFM/FTP includes a number of special subroutines that can be used to detect important events or even alter some of the plug-in's built-in behavior. The FMFTP_FocusChanged subroutine will be executed whenever something causes one of our File Browsers to become active or inactive. This can occur when the user clicks on another File Browser, navigates to a different page, etc. The FileList1_SelectionChanged subroutine will be executed whenever the number of selected items in FileList1 changes. The FileList2_SelectionChanged does the same for FileList2.


The variable [[FMFTP.ActiveClient].SelCount] combines the [FMFTP.ActiveClient] variable with the [ID.SelCount] variable. As we learned earlier, [FMFTP.ActiveClient] always contains the ID of the active File Browser, while [ID.Selcount] contains the number of selected items. We use this to determine if the active File Browser has any selected files. If one or more files are selected, the subroutine will enable the recycle button. If no files are selected, the recycle button will be disabled.


40. Click the OK button at the bottom of the Book Properties screen to save the Subroutine script.


41. You now have a functioning File Manager application. To test it, select Run (From Start) from VisualNEO Win's Book menu.


Note: Since our publication contains a StartUp action, you must use the Run (From Start) command.


42. Your screen should look something like this:



If everything went well, you should see the contents of your computer's hard drive on both the left and right sides of the screen. Files can be selected and dragged from one side to the other. Selected files can be sent to the Windows recycle bin by clicking the "Recycle" button. However, the icons here represent real files, so be careful not to disturb anything important! Please read the warning below.


If you receive any error messages, close the publication and return to the beginning of this tutorial and check your work.


WARNING: If you are operating in a corporate or organization environment, you must obtain permission from the server/website administrator or IT administrator before attempting to process files with NeoFM/FTP or any other tool. Please be extremely careful if you are experimenting with a live, mission critical website, server, workstation or stand-alone PC. It's certainly possible for someone who doesn't know what they are doing to accidentally delete important files or otherwise cause serious damage.


The sample "Basic File Manager.pub" included with NeoFM/FTP demonstrates how this simple tutorial can be expanded to create a more advanced application.