Local Files

Hi All

New to all this so total noob. Can someone please give me the correct way to load local files. I have a web view working no problem that will load various external url’s fine. If i want a folder in my app that contain what is essentially a mini website with instructions/pics embedded as html what the best way to do it?

Thanks in advance

Put this code in a PushButton Action event for example

Dim f As FolderItem f = GetOpenFolderItem("text/html") If f <> Nil Then HTMLViewer1.LoadPage(f) End If

Should get you going…
See HTMLViewer.LoadPage in Language Reference.

Firstly…thanks for the reply. I found that but just cant get it to work. Heres what I have:

[code]
If popupmenu1.ListIndex = 0 Then
HtmlViewer1.LoadURL(“http://google.co.uk”)

ElseIf popupmenu1.ListIndex = 1 Then
HtmlViewer1.LoadURL(“http://last.fm”)
Else
//
End if[/code]

I have two urls on a dropdown menu. What id like to be able to do is replace one of the above urls with an index.html dropped into the project but i can’t get it to work The closest i got was your code but that just gives a load option.

[code] If popupmenu1.listindex=0 then
Dim f As Folderitem
F=GetFolderItem(“G:\LPA\rest.html”)
HTMLViewer1.Loadpage(f)
else…

[/code]

Should work (G:\LPA\rest.html is a local file on my G drive in the LPA folder)

Thanks again. Is there no way of bundling the files with the application so they are included in the build then ? Id like to have it all in the app itself ?

Well I can only talk about windows. The way which works for me is to locate the folder which contains your exe file - copy all required files, databases etc to same folder as the exe then

Select all the files in the folder including folder (libs)
right click
send to compressing (zip) folder

Ship the zip file…(user double clips the zip to unzip it or use winzip/megazipper et al)

or use an installer like innosetup

Thanks fZ. Man…thats a shame. I guess its back to Xcode where you can definately reference and package local files. I thought id try this as it seemed much easier to grasp than C to program. Seems daft that you cant to be honest. You can reference pics and various other file types and package them up cant you though ?

Well don’t give up…That method works for me as I want to keep the files “external” as I usually modularize my app and have a few mini-apps with it which require the files. I am sure the gurus here can help you out. I know jpgs etc can be packaged so it may be possible. Just never had to do it myself.

Will do FZ thanks. Hopefully there is a way to do it ! I’ll hang on in grim desperation :slight_smile:

You can use a Copy Files build step to copy the files you want alongside your built app, perhaps in the Resources folder. Then your running app can simply look in that folder for the files and display them as described above.

Use Insert Build Step and select Copy Files. Then drag it so that it is after the OS build step in the Build Settings area. After that you can use the Build Step Editor to add the files you want to copy and choose the destination Jin the Inspector.

Hi Paul

Where can I find documentation regarding copy file option? Can’t seem to find it in the language ref

This is an IDE feature, so it is not in the Language Reference. Look in User Guide Book 3: Framework, Chapter 9: Building Your Applications, Section 2: Build Automation.

You could also copy the HTML text into a constant and write the html file in the app.open event each time the program is started.

Another approach is to use an .exe wrapper/compressor. These utilities wrap your exe and necessary files in a new executable. Everytime the executable is ran, the original exe and the other files gets unwrapped and can be used. For the user, this process is totally transparent. Note: only applicable for files that do not change, because you cannot put changed files back into the wrapper.

I use this approach for many years. If there are no accompanying files, I do use UPX as an .exe compressor a lot, due to the high compression factor and the speed of execution. Never had any problems.

Thanks for all your help on this. I completely understand the need for not being able to store changed files in the app bundle, but would have thought it should have been made easy to just drag a static folder into a project and reference it. I know there a thousands of iPhone/mac apps that use this loads for styled music players / info pages / all kinds of stuff. Would be a nice addition.

Im off to lookinto the copy files step ! Thanks you :slight_smile:

Exe. wrappers and compressor Windows only, that is…

Hi,
I use:

But it show me error: “Parameters are not compatible with this function [i]HTMLViewer1.LoadPage/i
Why? Thanks :slight_smile:

[quote=112023:@Krystof Jurecka]I use:

Dim f As FolderItem
f=GetFolderItem(“C:\Users\isb\Desktop
etronic\VARCHART_JGantt_JavaBeans_3.1_SR_0000\Samples\JGanttSample\JGanttSampleApplet.html”)
HTMLViewer1.LoadPage(f)
But it show me error: “Parameters are not compatible with this function HTMLViewer1.LoadPage(f)”[/quote]

You may want to make sure f is not nil. Are you sure the path is right ?

Path is right, when I copy this path to folder to “way”, it run chrome and display html page.

But yes, when I tried it into msgbox, it show me the same error…

EDIT: I use xojo 2014r2 and when I tried f=GetFolderItem(“C:\pokus.html”), it show me the same error. Need I any plugins?

Dim f As FolderItem f=GetFolderItem("C:\\Users\\isb\\Desktop\ etronic\\VARCHART_JGantt_JavaBeans_3.1_SR_0000\\Samples\\JGanttSample\\JGanttSampleApplet.html") HTMLViewer1.LoadPage(f), FolderItem.PathTypeShell