[Gambas-user] Problem with Exist & Open functions with filename containing spaces

Tobias Boege taboege at ...626...
Thu Mar 12 12:38:40 CET 2015


On Thu, 12 Mar 2015, John Rose wrote:
> On 12/03/15 10:37, Tobias Boege wrote:
> > Public Sub Main()
> >   Dim sPath As String = Temp$("with spaces")
> >   Dim hFile As Stream
> >   Dim sLine As String
> >
> >   File.Save(sPath, "some string")
> >
> >   Debug "Path =";; sPath
> >   Debug "Exist =";; Exist(sPath)
> >   Debug "Content ="
> >   hFile = Open sPath For Input
> >   For Each sLine In hFile.Lines
> >     Debug "  "; sLine
> >   Next
> >   Close #hFile
> > End
> I've tried that program and it didn't display anything in the Console
> window. I was not able to compile the attached Test app with Debug as
> when I tried to add the gb.debug component (by clicking its checkbox
> which did put an x in it) using Project Properties, it did not enable
> the OK button. When I closed the Project Properties window & reopened
> it, the checkbox was not marked with an x. So I put in Print statements
> and it did not even show their results on the Console window when I ran
> the Test app.
>

The attached file was a Gambas script. You could (and should) have run it
as-is. Your project is a GUI one where you blindly put the code in a Form's
class file. But my code had a Main() procedure which is already implemented
in the Form class. You have incorrectly overridden that implementation by
inserting my Main() procedure (which was made for a script or console
application).

> BTW I think that the 'File or Directory does not exist'
> window appears because I have a 'Catch' followed by
> 'Message.Warning(ERROR.Text)' in the coding of the relevant Sub. Is it
> possible to show the line number when the Catch 'catches'? I've also
> tried putting Breakpoints in my app but that didn't help.

To clarify: what shows the error? A message box or a popup? Because you said
it was a popup (which I picture as a Balloon or tooltip-like window) and now
you conjecture your Message.Warning() call may be it. But if it was a popup,
as I picture it, it cannot be caused by a Message.Warning().

You get the error line with Error.Where. You could also leave the Catch out
and let the IDE display the error by itself. The IDE is good enough at that.

Regards,
Tobi

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk




More information about the User mailing list