[quote=59954:@Niles Mitchell]Well that sucks. Why can’t you install a file from the exe? All kinds of development tools support this, WiseScript, AutoIT, etc…
I thought that’s what we’re were talking about. Why else would you use the path you supplied? It’s pointed internally.[/quote]
Do you want your code to work, or keep complaining Xojo does not work as WiseScript ? If your intent is simply to complain, nobody can help you
Here is code from Kem Tekinay to save a file placed in the code. You can probably use that to save the file to applicationdata and then open it :
[code]Say you have your files in a zip file called MyResources.zip. Drag that file into your project, and you get a constant named MyResources which is a string containing the contents of the file. To write it back out is
dim f as FolderItem = SpecialFolder.ApplicationData.Child(“myapp”).Child(“MyResources.zip”)
dim t as TextOutputStream = t.Open(f)
t.Write MyResources
[/code]
I want to know why a development tool that’s been around since 1998 can’t support a simple feature that almost every other development kit for windows supports. Is that complaining, a fair question coming from a paying customer, an attendee of last years development conference, and a supporter of this platform.
If your image is already in your project/executable you can also base64encode it and then just create an HTML page on the fly (and in memory) and then use the LoadPage method of the HTMLViewer…
dim f As FolderItem = app.ExecutableFile.Parent.Parent.Child("Resources").Child("FILE NAME.gif")
dim s as string = ReplaceAll(f.NativePath, " ", "%20")
HTMLViewer1.LoadURL("file://"+s)
but use ‘PathTypeShell’ not NativePath
'f = GetFolderItem(name,0)
f = new FolderItem(name,FolderItem.PathTypeShell)
t = f.CreateBinaryFile("pdf")
t.Write me.buffer
t.close
' f.Launch
pdfpreview.Openpdf(name)
I understand Niles’ frustration. It “seems” like there ought to be an easier way. That said…if you are working with an HTML viewer, I’d expect that it will only accept…well… HTML. I’m using Daniel Taylor’s WebLIstBoxTD which allows you to put HTML in a subclassed listbox. I think I had done this once before long ago…and Daniel has a function which “processes” a picture into HTML to prepare it for display in the listbox. I noted Shao Sean’s handy little block of code above. I “slapped” the code in a module… and used it to encode once of my internal images and presto. I can pop it right into Daniel’s listbox. I think that’s pretty slick. I do still wish the “standard” listbox was slightly more feature rich – I see where people are using the canvas to to amazing things. I also see where you can roll your own code for basics like sorting and changing columns widths, adding checkboxes, popups, an Links to The XOJO listbox. I’m used to tools like the Infragistics “smart grid” etc. Of course…the smart grid IS available as a pure HTML 5 solution…I bet I could jam one of those in my XOJO projects somehow. (Probably can’t generate XOJO “events” …but it’d be pretty great for displaying and grouping result data.
Sure, there always ought to be an easier way. But it should be no excuse for refusing to learn.
In programming, there are two possible attitudes : pragmatism, and bitter recrimination. The latter never produce any other result than frustration. Accepting the limitations of a tool as opportunities to understand how to overcome these impediments, and grow in the process, is the way to produce outstanding code.
In life, not being able to adapt to reality has been recognized as a grave psychological disorder.
Xojo is not perfect, neither are other human creations. When some features seem to be missing, the way is not to ask again and again for it at nauseum like a brat, but to file a sensible and articulate feature request.
And thanking all members who tried to help would seem in order.
Agreed that people should be grateful that people take time out of their busy lives to try and help solve someone else’s dilemma. I of course am always thankful to the generous support of XOJO developers I’ve encountered. I try not to whine (too much ) about “missing” features, or bugs and the like. Sometimes I get answers that seem… a bit less than helpful. Still no reason to be rude about it. It’s the classic case of going to the Doctor because your arm hurts when you move it a certain way…and the Doctor says…then don’t move it like that. Fortunately…the majority of the XOJO developers I’ve met (like you) have been very generous with their time and helpful. Re: the Psychological Disorder of Adaptation – That may well be, however; it has been said that “Reasonable people adapt themselves to the world. Unreasonable people try to adapt the world to themselves. All progress comes from unreasonable people.” - Sam Elliot
If Steve Wozniak had known that what he was constructing was considered impossible by luminaries, he may have renounced. Around the turn of last century, mathematicians had developed aerodynamic equations that showed the beetle could not fly, One said : “The beetle has wings too small to fly, but he does not know … so it flies”.
I never considered bad in itself to dream, or to wish for things to be better. It is necessary to think out of the box to attain goals often considered impossible. Incidentally, thinking out of the box is the definition of a workaround.
What I find sad is an attitude of refusing all solutions presented, under the pretext that things should be otherwise. Such a behavior is the contrary of progress. It is pure and simple paranoia : “the world will not conform, so I hate it, and everybody around me”. True innovators dont pout in their corner : they go out and take risks to see their vision come true.
This works great on OS-X and Linux, but not on Windows when running from IDE. When doing so, for some reason you’ll get a NilObjectException. Consider the following code:
dim w as new wAgreement()
w.Path = HelpPath
w.File = AgreementFile
if w.Load() then
w.ShowModal()
if w.Agreed then
TSettings.AgreeLicense = true
end if
end if
Here wAgreement is a window with a HTMLViewer. When running the code with a valid file url like above, there will be a NilObjectException at w.ShowModal. Interestingly, when the file does not exist, the window pops up normally with a correct error message in the HTMLViewer. Clearly this is a bug, and it existed in RS2011r4 and apparently still does today, or they must have fixed it somewhere in the last 6 months.
This works great on OS-X and Linux, but not on Windows when running from IDE. When doing so, for some reason you’ll get a NilObjectException. Consider the following code:
dim w as new wAgreement()
w.Path = HelpPath
w.File = AgreementFile
if w.Load() then
w.ShowModal()
if w.Agreed then
TSettings.AgreeLicense = true
end if
end if
Here wAgreement is a window with a HTMLViewer. When running the code with a valid file url like above, there will be a NilObjectException at w.ShowModal. Interestingly, when the file does not exist, the window pops up normally with a correct error message in the HTMLViewer. Clearly this is a bug, and it existed in RS2011r4 and apparently still does today, or they must have fixed it somewhere in the last 6 months.[/quote]
Are you absolutely certain of the file location ? Have you tried pointing to a file on the desktop ?
Windows and Mac OS X do not store files at the same place, and Windows creates a debug folder when run that is different from the place where the source code is. You may want to check TPSF (TPSpecialFolders) from Tim Parnell that helps in locating them. http://timi.me/files/TPUpdates.xojo_binary_code
Yes, Michel, I am absolutely sure about the file location. I debugged and checked the paths for the Windows platform. It should work. The location is C:\Program Files\MyProg\Help. The standalone is run from C:\Program Files\MyProg and it finds the location using the exact same path perfectly. So it is not an issue of having files next to the executable.
I am not too sure you are going the right way about this. You should not need “file://” if s is a folderitem.URLPath. If s is ShellPath it messes up because in Windows shellpath starts with the drive letter and not by / as in Mac.
Here is what I would do :
Dim s as folderItem = SpecialFolder.Pictures.Child("mypic.png")
if s <> nil and s.exists then
HTMLViewer1.LoadURL(s.URLPath)
end if
In general, I avoid literal path like a plague when cross platform is concerned.
[quote=181283:@Michel Bujardet]I am not too sure you are going the right way about this. You should not need “file://” if s is a folderitem.URLPath. If s is ShellPath it messes up because in Windows shellpath starts with the drive letter and not by / as in Mac.
Here is what I would do :
Dim s as folderItem = SpecialFolder.Pictures.Child("mypic.png")
if s <> nil and s.exists then
HTMLViewer1.LoadURL(s.URLPath)
end if
In general, I avoid literal path like a plague when cross platform is concerned.[/quote]
Of course, using FolderItem is the right way. Nonetheless, feeding a “wrong” url should generate the proper error in any case. The NilObjectException when run from the IDE isn’t right and should be considered a bug IMHO.