[futurebasic] Re: [FB] FB More files

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2012 : Group Archive : Group : All Groups

From: Bernie <fblist.bw@...>
Date: Fri, 22 Jun 2012 09:08:09 +0100
Ted wrote:

> is gURL still valid an hour after it was found?

Yes, providing it has not been released.

> Presuming, of course, that the file hasn't been moved in the interim. Oh dear... What does that do??


The file will not be found. Consider creating a file reference URL.
'---------------
/*
   [1] Save
   [2] Move the file
   [3] Open
*/
begin globals
dim as CFURLRef gUrl// file reference URL
end globals

_mainWnd = 1
begin enum 1
_cSaveBtn
_cOpenBtn
end enum

_openBatchFileNum = 2

local fn SaveBtn
'~'1
dim as Str255     s
dim as CFURLRef   url

s = files$( _CFURLRefSave, "Create a new Surface Tension project", "Teds files", @url )
long if ( s )
open "O", _openBatchFileNum, @url
print #_openBatchFileNum, "Hello"
close #_openBatchFileNum
gUrl = fn CFURLCreateFileReferenceURL( _kCFAllocatorDefault, url, NULL )
CFRelease( url )
end if
end fn

local fn OpenBtn
'~'1
dim as Str255   s

long if ( gUrl )
open "I", _openBatchFileNum, @gUrl
line input #_openBatchFileNum, s
close _openBatchFileNum
print s
end if
end fn

local fn BuildWindow
'~'1
dim as Rect   r

SetRect( r, 0, 0, 516, 366 )
appearance window -_mainWnd, "File Reference URL", @r, _kDocumentWindowClass

SetRect( r, 20, 326, 90, 346 )
appearance button _cSaveBtn,,,,, "Save", @r, _kControlPushButtonProc

SetRect( r, 102, 326, 172, 346 )
appearance button _cOpenBtn,,,,, "Open", @r, _kControlPushButtonProc

window _mainWnd
end fn

local fn DoDialog
'~'1
dim as long   ev, id

ev = dialog( 0 )
id = dialog( ev )
select ( ev )
case _btnClick
select ( id )
case _cSaveBtn : fn SaveBtn
case _cOpenBtn : fn OpenBtn
end select
end select
end fn

fn BuildWindow

on dialog fn DoDialog

do
HandleEvents
until gFBQuit
'---------------