Help Showurl Doesn't exist

I have a web app that creates an excel file, I then need to download it, here is the code:


'f is the folderitem pointing to the excel file

  Dim wf as WebFile
  
  wf = WebFile.Open(f, false)
  
  showurl(wf.url)
  

The showurl causes a compile error: This item does not exist???

What is going on.

Is it not the same as https://forum.xojo.com/30799-download-binarystream ?

wf should be a property of the WebPage, a module or session.

As it stands, the webfile gets out of scope when the method ends and the browser cannot download anything.

I was doing more research about the Webfile and tried it. The point is why does the compiler complain about it. I’m against a deadline and thought this might get more views as it’s a different heading.

I tried your rather simple code and did not get any warning. Is it really the actual code that creates an error ?

You want to look at /Examples/Web/Downloading/Downloading.xojo_binary_project

I did, it’s doesn’t answer the questions.

That is creating a text file and it compiles. The example doesn’t mention anything about downloading a binary file.


  If TextFile = Nil Then
    // Create a text file to download
    TextFile = New WebFile
    TextFile.MimeType = "text/plain"
    TextFile.ForceDownload = True
    TextFile.FileName = "TextFile.txt"
    
    Dim d As New Date
    d.GMTOffset = Session.GMTOffset
    
    TextFile.Data = "Hello World to " + Session.RemoteAddress + " at " + d.ShortDate + " " + d.ShortTime
    
    // The WebFile.Downloaded event handler is called when the browser
    // requests the file for downloading. This code maps that event handler
    // to the FileDownloaded method on this web page.
    AddHandler TextFile.Downloaded, AddressOf FileDownloaded
  End If
  
  // Showing the URL prompts the browser to download it
  ShowURL(TextFile.URL)

I have made wf a property of a module. Same problem.

I have been using a slightly modified version of Downloading to serve my customers since 2013. The downloaded files are zip binary archives.

So what am I doing wrong?

I don’t know. I tested both your posted code and it works just fine.

Usually “does not exist” stems from mispelling… Or wrong scope …

Arggg I hate these mysterious problems.

Clear the cache.
Triple check that you aren’t compiling a console app.

It’s a web app. I’ve been working on it for a few weeks. I’m just trying to add a feature that my BOD wants.

How can the Cache have anything to do with the compiling?

Strange things in Xojo often come down to a cache issue.
If you don’t want to try it, no problem. :slight_smile:

Where does your code exist? On a WebPage? Elsewhere?

The code is in a module.

The help suggests that the best place for this is as an event or method of a webcontrol.
Where it would be called as

me.ShowUrl (…)

Perhaps the fact this is in a module means that there is no suitable ‘me’ to provide the ShowUrl.
What happens if you put it in the action event of a webbutton?

The global ShowUrl function does not exist in web apps
What DOES exists is one on WebSession and one on WebControl

And that makes sense as in a web app you have to know WHICH session to invoke the show url on so it shows in the right persons browser

Jeff you win! That was it. Moved into a form and it worked!!

Thanks to all.