New topic: 

Displaying previous selected folder

<http://forums.realsoftware.com/viewtopic.php?t=44796>

         Page 1 of 1
   [ 6 posts ]                 Previous topic | Next topic          Author  
Message        rkamarowski          Post subject: Displaying previous selected 
folderPosted: Sat Jul 21, 2012 12:35 pm                         
Joined: Wed Nov 26, 2008 12:05 pm
Posts: 18                I'm storing a 'location folder' text in a button 
caption using the following code:

Dim dlg As New SelectFolderDialog
Dim f As FolderItem
dlg.ActionButtonCaption = "Select"
dlg.Title = "Download Location"
dlg.PromptText = "Select Location"
dlg.InitialDirectory = SpecialFolder.Documents
// choose folder
f = dlg.ShowModal
If f <> Nil Then
  // Use the folderitem here
  Me.Caption = dlg.Result.AbsolutePath
Else
  // User cancelled
End If


If the user has already selected a folder, how can I default to that location 
when the user clicks the button again.

I have tried over and over, as well as searched this forum.  Please help.

bob k.   
                             Top                Jason_Adams          Post 
subject: Re: Displaying previous selected folderPosted: Sat Jul 21, 2012 1:31 
pm                                 
Joined: Fri Nov 10, 2006 4:10 pm
Posts: 1631
Location: Michigan, USA                If I'm understanding you correctly, you 
want to set the Initial Directory to reflect whatever the last selected 
directory was. To do this, you'd have to store the FolderItem as a local 
property. When you run this code, check if it's Nil, and set the Initial 
Directory if it's not. Here's an alternative using the Static keyword, but it 
would be very similar for a local property as well.

Static fLast As FolderItem
Dim dlg As New SelectFolderDialog
Dim f As FolderItem

dlg.ActionButtonCaption = "Select"
dlg.Title = "Download Location"
dlg.PromptText = "Select Location"

If fLast Is Nil Then
  dlg.InitialDirectory = SpecialFolder.Documents
Else
  dlg.InitialDirectory = fLast
End If

// choose folder
f = dlg.ShowModal
If Not (f Is Nil) Then
  // Use the folderitem here
  Me.Caption = dlg.Result.AbsolutePath
  fLast = f
Else
  // User cancelled
End If
      
_________________
Windows 7 Ultimate x64
Windows XP Pro SP3
Ubuntu 11.04 via Virtual Box
RS Enterprise 2011r4

Programming Tutorials & Free Projects: http://www.JasonTheAdams.com
"Christianity has not been tried and found wanting; it has been found difficult 
and not tried." - G.K. Chesterton  
                             Top                rkamarowski          Post 
subject: Re: Displaying previous selected folderPosted: Sat Jul 21, 2012 2:08 
pm                         
Joined: Wed Nov 26, 2008 12:05 pm
Posts: 18                Perfect!

thank you,
bob k.   
                             Top                rkamarowski          Post 
subject: Re: Displaying previous selected folderPosted: Sat Jul 21, 2012 2:22 
pm                         
Joined: Wed Nov 26, 2008 12:05 pm
Posts: 18                uhhhh... I jumped the gun.

This data is stored in a file, so when a new entry is selected I need to 
convert the saved text to a folderItem.

I have an application property setup as 'DownLoadFolder As FolderItem'.  How do 
i get the string field from the database into the DownLoadFolder property?   
                             Top                timhare          Post subject: 
Re: Displaying previous selected folderPosted: Sat Jul 21, 2012 2:53 pm         
                
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 11537
Location: Portland, OR  USA                GetFolderItem can accept an absolute 
path.  Note, however, that storing an absolute path is not recommended on OS X 
systems.  You should be fine on Windows and Linux.  If you want to support all 
platforms, use GetSaveInfo instead.   
                             Top                rkamarowski          Post 
subject: Re: Displaying previous selected folderPosted: Sat Jul 21, 2012 3:38 
pm                         
Joined: Wed Nov 26, 2008 12:05 pm
Posts: 18                Still not working.  Here's what I have when I select a 
table entry:

SessionDownloadFolder = GetFolderItem(rs.Field("DownLoadLocation").StringValue)

Here's the button action code:

Dim dlg As New SelectFolderDialog
Dim f As FolderItem
dlg.ActionButtonCaption = "Select"
dlg.Title = "Download Location"
dlg.PromptText = "Select Location"
// determine last location
If App.SessionDownloadFolder Is Nil then
  dlg.InitialDirectory = SpecialFolder.Documents
Else
  dlg.InitialDirectory = App.SessionDownloadFolder
End If
// choose folder
f = dlg.ShowModal
If Not (f is Nil) Then
  // Use the folderitem here
  Me.Caption = dlg.Result.AbsolutePath
  App.SessionDownloadFolder = f
  // User cancelled
End If
   
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 6 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

[email protected]

Reply via email to