1. Jason Lipman
  2. PowerBuilder
  3. Friday, 22 April 2022 19:15 PM UTC

Hello Fellow PB People,

Powerbuiler 2019 R2

Here's one I have not run into yet.

When utilizing SaveAs() with a valid filename in the parameters, it will not allow the popup, but automagically saves to the current directory.

To assist the users, I want them to have the SaveAs popup dialogue WITH a pre-determined report name.

Anyone run into this? Is there a simple solution so I do not need to code for it extensively?

Thanks,

Jason

Accepted Answer
John Fauss Accepted Answer Pending Moderation
  1. Friday, 22 April 2022 21:25 PM UTC
  2. PowerBuilder
  3. # Permalink

Hi, Jason - 

You might want to take a look at the "GetFileName" sample program at Roland Smith's TopWizProgramming web site:

https://www.topwizprogramming.com/freecode_getfilename.html

It utilizes the Windows Open/Save dialog windows via API functions instead of using the PB dialogs. The dialog windows look terrific and they work great!

Regards, John

Comment
  1. Jason Lipman
  2. Tuesday, 26 April 2022 13:34 PM UTC
I think this was the way to go. Thanks for the lead, John! And thanks to Roland at TopWiz for his excellent work and examples from which to extract!



I did open a ticket with Appeon to have them add the ability to place a pre-determined filename into the SaveAs() functionality.



Jason
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 22 April 2022 20:28 PM UTC
  2. PowerBuilder
  3. # 1

Hi Jason;

  This works for me ...

String		ls_file_name		=	""
String		ls_path			=	"C:\Dev\PB2021\CIPTest"
GetFileOPenName ( "Select a File!", ls_path,  ls_file_name, "Text", "Text Files (*.txt), Chris*.txt", ls_path, 32768  )
MessageBox ("File selected", ls_file_name)

 

I can then select Chrs.txt or Chris1.txt OR over-ride the default name with (in this case) "chris3.txt"

Selection comes back as either Chris.txt or Chris1.txt OR supplied name Chris3.txt (in this example) after the GFON command into the MessageBox() command, as follows...

HTH

Regards ... Chris

Comment
There are no comments made yet.
Jason Lipman Accepted Answer Pending Moderation
  1. Friday, 22 April 2022 19:54 PM UTC
  2. PowerBuilder
  3. # 2

Chris,

I was already playing around with GetFileOpenName() and GetFileSaveName(). When passing a filename argument string, it appears to NOT populate the dialogue with it. Rather, it seems to only accept what the user types or selects in the Treeview. This is not appearing helpful unless I am getting it wrong?

Jason

Comment
  1. John Fauss
  2. Friday, 22 April 2022 20:24 PM UTC
Have you tried GetFileSaveName instead of GetFileOpenName? It works a little differently. If you're prompting the user for the path/name of a file to be saved, it would seem that using GetFileSaveName would be more appropriate.
  1. Helpful 1
  1. Chris Pollach @Appeon
  2. Friday, 22 April 2022 20:30 PM UTC
Another great suggestion John! :-)
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 22 April 2022 19:31 PM UTC
  2. PowerBuilder
  3. # 3

Hi Jason;

  Yes, the SaveAs() command does not have such an option. Either you do not supply the file name (empty or NULL) and the App user will then be prompted for the location & file name. However when you supply a file name to the SaveAs(), the App user does not see the pop-up selection dialogue. To me, it looks like we would need another SaveAs() argument (say True/False) as to whether the PB runtime needs to show the File Selection dialogue even with a supplied file name. Unfortunately, this would require an Enhancement Request.

  The workaround though would be to use the GetFileOpenName() command first to allow the user to either accept or over-ride the suggested "save as" file name first. Then feed that response into the SaveAs() command with their qualified file name they selected (over-rode) from the GFON command.  HTH

Regards ... Chris

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.