How can you use the FILEOPEN in BBj to create a Filedialog?

51 Views Asked by At

In the Documentation it is stated like this: 'FILEOPEN'(prompt,path,name,ext[,filters[,mode]])

But what parameters do you need to use to be able to display the dialog? Any samples?

1

There are 1 best solutions below

0
On BEST ANSWER

Parameters are documented in this page

Parameter Description
prompt Text to display in the title bar of the dialog.
path Default directory for the file to be opened in the dialog.
name Default name for the file to be opened in the dialog. Use the empty string ("") to avoid setting a default filename.
ext Default extension (usually 3 characters, do not include the dot) for the file to be opened in the dialog. Use the empty string ("") to avoid setting a default extension.
filters One or more filters in the following format: "text description" + $0a$ + "mask" [+$0a$ + "text description" + $0a$ + "mask" ...] The mask specifies an extension, in the format ".ext" or "."; two or more masks are separated with semicolons. The filter, if included, indicates which files will appear in the list. For example: REM Illustrate the use of the FILEOPEN() function REM Build filters for brc/arc and all files FILTER$="Binary Resource Files"+$0a$+".brc;.brf" FILTER$=FILTER$+$0a$+"ASCII Resource Files"+$0a$+".arc" FILTER$=FILTER$+$0a$+"All Files (.)"+$0a$+"." REM Starting directory is the default Directory FILE_DIR$="" REM Use FILEOPEN() to get name of file to open FILE_NAME$=FILEOPEN("Open Resource File",FILE_DIR$,"","",FILTER$) REM display file name returned PRINT FILE_NAME$
rem ' clientfile.txt
precision 6
tc! = bbjapi().getThinClient()
fs! = tc!.getClientFileSystem()
filter$ = ""
filter$ = filter$ + "Text Files (*.txt)"+$0a$+"*.txt"+$0a$
filter$ = filter$ + "HTML Files (*.htm;*.html)"+$0a$+"*.htm;*.html"+$0a$
filter$ = filter$ + "Image Files (*.png;*.jpg;*.bmp;*.gif)"+$0a$+"*.png;*.jpg;*.bmp;*.gif"+$0a$
filter$ = filter$ + "All Files (*.*)"+$0a$+"*.*"+$0a$
i = msgbox("Test client fileopen + copy file from client to server")
clientfile$ = fileopen("Pick a client file","","","",filter$,mode="client")
i = msgbox(clientfile$,0,"Selected client file")
if pos("::"=clientfile$) then goto eoj
cf! = fs!.getClientFile(clientfile$)
i = msgbox("Copy "+clientfile$+" to the server")
t = tim
serverfile$ = cf!.copyFromClient()
t = tim - t
t = t * 3600
serverfile = unt
open (serverfile)serverfile$
serverfile$ = fid(serverfile)(9)
bytes = dec(fin(serverfile)(1,4))
close (serverfile)
i = msgbox("Copied client file "+clientfile$+" to server file "+serverfile$+" ("+str(bytes)+" bytes; "+str(t)+" seconds)",0,"Copied from client to server")
i = msgbox("Test server fileopen + copy file from server to client")
serverfile$ = fileopen("Pick a server file","","","",filter$)
i = msgbox(serverfile$,0,"Selected server file")
if pos("::"=serverfile$) then goto eoj
clientfile! = new java.io.File(serverfile$)
clientfile$ = clientfile!.getName()
clientfile$ = filesave("Save to client","",clientfile$,"",filter$,mode="client")
if pos("::"=clientfile$) then goto eoj
i = msgbox("Copy server file "+serverfile$+" to client file "+clientfile$)
cf! = fs!.getClientFile(clientfile$)
cf!.copyToClient(serverfile$)
i = msgbox("Copied server file "+serverfile$+" to client file "+clientfile$,0,"Copied from server to client")
eoj:
release