"Save as" dialog box
"Save as" dialog box
Hello all,
In a Purebasic program, upon clicking a button, I want the "Save As" dialog box to appear in order to choose where I want to save a file.
I couldn't find a matching gadget!
Thank you for your help
In a Purebasic program, upon clicking a button, I want the "Save As" dialog box to appear in order to choose where I want to save a file.
I couldn't find a matching gadget!
Thank you for your help
Re: "Save as" dialog box
what about SaveFileRequester()
Code: Select all
StandardFile$ = "C:\autoexec.bat" ; set initial file+path to display
; With next string we will set the search patterns ("|" as separator) for file displaying:
; 1st: "Text (*.txt)" as name, ".txt" and ".bat" as allowed extension
; 2nd: "PureBasic (*.pb)" as name, ".pb" as allowed extension
; 3rd: "All files (*.*) as name, "*.*" as allowed extension, valid for all files
Pattern$ = "Text (*.txt)|*.txt;*.bat|PureBasic (*.pb)|*.pb|All files (*.*)|*.*"
Pattern = 0 ; use the first of the three possible patterns as standard
File$ = SaveFileRequester("Please choose file to save", StandardFile$, Pattern$, Pattern)
If File$
MessageRequester("Information", "You have selected following file:"+Chr(10)+File$, 0)
Else
MessageRequester("Information", "The requester was canceled.", 0)
EndIf
Just because it worked doesn't mean it works.
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
PureBasic 6.04 (x86) and <latest stable version and current alpha/beta> (x64) on Windows 11 Home. Now started with Linux (VM: Ubuntu 22.04).
Re: "Save as" dialog box
Hello Axolotl,
Actually, I expressed myself badly:
I have a lot of videos on an external drive. I wrote a program that allows you to display them, search them, read them, etc., and I want, when I select one in a ListIconGadget, to be able to copy it to a USB stick or other external disk, etc...
Actually, I expressed myself badly:
I have a lot of videos on an external drive. I wrote a program that allows you to display them, search them, read them, etc., and I want, when I select one in a ListIconGadget, to be able to copy it to a USB stick or other external disk, etc...
Re: "Save as" dialog box
Use PathRequester() and CopyFile().
Re: "Save as" dialog box
Hello Quin,
I applied what you wrote and it's exactly what I wanted.
Thank you all for your help
I applied what you wrote and it's exactly what I wanted.
Thank you all for your help
Re: "Save as" dialog box
Hello everyone,
I applied the instructions given by Quin in my program and it works as I want.
But, for copying a video it can take a while (especially if it's on a USB stick), I would like to show a copy progress bar. However, I don't know how to know how long the copy will take!
To do this, I need to know the size of the video but also the data transfer rate when copying!
Do you know if this is possible?
Thank you for your help
I applied the instructions given by Quin in my program and it works as I want.
But, for copying a video it can take a while (especially if it's on a USB stick), I would like to show a copy progress bar. However, I don't know how to know how long the copy will take!
To do this, I need to know the size of the video but also the data transfer rate when copying!
Do you know if this is possible?
Thank you for your help
- Mindphazer
- Enthusiast
- Posts: 460
- Joined: Mon Sep 10, 2012 10:41 am
- Location: Savoie
Re: "Save as" dialog box
You can check this thread : viewtopic.php?t=74835
MacBook Pro 16" M4 Pro - 24 Gb - MacOS 15.4.1 - Iphone 15 Pro Max - iPad at home
...and unfortunately... Windows at work...
...and unfortunately... Windows at work...
Re: "Save as" dialog box
The precision level on most progress bars is about as accurate as a weather forecast from a fortune cookie.
If task cannot be done in the background, one advice is to have simple animated spinner just showing "please wait"

If task cannot be done in the background, one advice is to have simple animated spinner just showing "please wait"

Spec: Linux Mint 20.3 Cinnamon, i7-3770K, 16GB RAM, RTX 2070 Super
Re: "Save as" dialog box
Yeah, honestly don't worry about accuracy too much, as long as the users know something is happening. A really simple solution would just be to divide the file size by 100, and use that to tell when to increase your progress bar.
Re: "Save as" dialog box
Thank you all, I will test the different codes that I found with the link that Mindphazer gave me
See you
See you
Re: "Save as" dialog box
Hello everyone,
I adapted the netmaestro code that I found with the link Mindphazer gave me and integrated it into my program. It works really well:
I'll try to write a little example code and post it on the forum.
Now I have another question:
When I copy videos to a USB stick (with the netmaestro code), when the stick does not have enough space, the code only copies part of the video, which is not correct and does not 'indicates no error!
Question: can we, with Purebasic or an API, know the available space on a USB key (or an external disk)?
Thank you for your help
I adapted the netmaestro code that I found with the link Mindphazer gave me and integrated it into my program. It works really well:
I'll try to write a little example code and post it on the forum.
Now I have another question:
When I copy videos to a USB stick (with the netmaestro code), when the stick does not have enough space, the code only copies part of the video, which is not correct and does not 'indicates no error!
Question: can we, with Purebasic or an API, know the available space on a USB key (or an external disk)?
Thank you for your help
Re: "Save as" dialog box
From RSBasic API list (Strings translated)jak64 wrote: Sun Oct 01, 2023 1:21 pm Question: can we, with Purebasic or an API, know the available space on a USB key (or an external disk)?
Code: Select all
EnableExplicit
Define lpFreeBytesAvailable.q
Define lpTotalNumberOfBytes.q
Define lpTotalNumberOfFreeBytes.q
GetDiskFreeSpaceEx_("C:\", @lpFreeBytesAvailable, @lpTotalNumberOfBytes, @lpTotalNumberOfFreeBytes)
Debug "Free space : " + Str(lpFreeBytesAvailable/1024/1024/1024) + " GB"
Debug "Space used : " + Str((lpTotalNumberOfBytes-lpFreeBytesAvailable)/1024/1024/1024) + " GB"
Debug "Total space : " + Str(lpTotalNumberOfBytes/1024/1024/1024) + " GB"

Re: "Save as" dialog box
Question: can we, with Purebasic or an API, know the available space on a USB key (or an external disk)?
This is very old, but maybe this will help...
Code: Select all
Procedure.s GetDiskSpace(DriveLetter.s)
; ------------ Get Disk Space by Timo Harter (Freak) -------
;
; Works even with high values (up to 2097152 GB)
; Returns values in MegaByte
;
; Useage: GetDiskSpace("c:\")
; ----------------------------------------------------------
drive.s = DriveLetter
Structure Quad2
L1.l
L2.l
EndStructure
GetDiskFreeSpaceEx_(@drive, FB.Quad2, TB.Quad2, TFB.Quad2)
TB.Quad2\L1>>20
TB.Quad2\L2<<12
TotalMB.l = TB.Quad2\L1 + TB.Quad2\L2
TFB.Quad2\L1>>20
TFB.Quad2\L2<<12
FreeMB.l = TFB.Quad2\L1 + TFB.Quad2\L2
UsedMB.l = TotalMB - FreeMB
MessageRequester("Disk Size","Space Total: "+Str(TotalMB)+" MB"+Chr(13)+"Space Free: "+Str(FreeMB)+" MB"+Chr(13)+"Space Used: "+Str(UsedMB)+" MB",0)
;End
EndProcedure
;===================================================================
DriveLetter.s = "c:\"
Debug GetDiskSpace(DriveLetter.s)
- It was too lonely at the top.
System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
Re: "Save as" dialog box
Thank you Marc56us and blueb for your help.
I used Marc56us' code and it works great.
See you
I used Marc56us' code and it works great.
See you