dialog.openfile to message

Post

Posted
Rating:
#1 (In Topic #1353)
Regular
theyikes is in the usergroup ‘Regular’
Hi again! I'd be screwed without this forum :) Ok I'm trying to get the results of a Dialog.Openfile to a simple message. I've tried a lot of things but I'm not having any luck. Anyway here's what i have at the moment :

Dim opensf As String
opensf = Dialog.OpenFile()
Message(opensf)
.

I know it's probably something simple but i can't seem to wrap my head around it..

Anyone?
Online now: No Back to the top

Post

Posted
Rating:
#2
Regular
theyikes is in the usergroup ‘Regular’
I've tried this:

   If Dialog.OpenFile() Then
    Message.Info("Selected file: " & Dialog.Path)
  Else
    Message.Info("Nothing selected")
  Endif

But I jujst keep getting the Nothing Selected error.
Online now: No Back to the top

Post

Posted
Rating:
#3
Regular
theyikes is in the usergroup ‘Regular’
Ok I took a step back and did some thinking and i came up with this which seems to work:

  Dim myresult As String
  myresult = Dialog.OpenFile()
  Message(Dialog.Path)
Online now: No Back to the top

Post

Posted
Rating:
#4
Guru
BruceSteers is in the usergroup ‘Guru’
Do you even read any of our replies to your other posts ?  :lol:

Read this Gambas One - Gambas ONE

I explained Dialog commands return an error value , not a filename and not True if all is okay.

Dialog.OpenFile() is no different to Dialog.SaveFile()

So
Dialog.OpenFile() returns True if cancelled or False if selected.

So your code is the wrong way round.

It should be like this

Code (gambas)

  1. If Dialog.OpenFile() Then
  2.   Message.Info("Nothing selected (canceled)")
  3.   Message.Info("Selected file: " & Dialog.Path)
  4.  
Online now: No Back to the top

Post

Posted
Rating:
#5
Guru
BruceSteers is in the usergroup ‘Guru’
I can assume from your struggles that you are not even reading the wiki either.
/comp/gb.qt4/dialog/openfile - Gambas Documentation

How to use Dialog.OpenFile properly is all very clear there. Examples and all

If as you say "you aspire to be like me" with gambas coding then you really need to use and study the gambas wiki more.
That's how i learned all the simple stuff.

 ;)
Image

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#6
Guru
BruceSteers is in the usergroup ‘Guru’
The simplest way to get what you want is this…

Message Dialog.Path if Dialog.OpenFile() is False (meaning no error/no cancel)

Code (gambas)

  1. If Not Dialog.OpenFile() Then Message(Dialog.Path)
  2.  
Online now: No Back to the top

Post

Posted
Rating:
#7
Regular
theyikes is in the usergroup ‘Regular’
 Ok I put my hands up and i do admit I haven't exactly been replying to your messages. I just get so caught up it never occurs to me to be polite enough to respond to all your advice. I have read them and yes they ALL work. I'm genuinely sorry guys but thanks again for all your help. As for the wiki page it's good but sometimes it's a little overwhelming and a lot to take in for a new comer. I PROMISE that from now on I WILL reply.
Online now: No Back to the top

Post

Posted
Rating:
#8
Guru
BruceSteers is in the usergroup ‘Guru’
 I was not asking that because I wanted you to reply. that's nothing to do with what i am saying.

I asked because the problems you were having here with your first examples are all explained in that other post.

I'm just not sure how you had these issues unless you had not read the other posts replies where it was explained.

To answer this post i've just had to repeat what i said in that one.
Online now: No Back to the top
1 guest and 0 members have just viewed this.