/*
** $VER: FilesToLoview.dopus 1.1 (23.03.1012) xenic
** based on SelectedFilesToFilelist.dopus 1.03 (21.05.2005)
** by Opi 
**
** write all selected filenames in the active lister to a file
** defined in the lines "destdir = ..." & "file = ..."
** after writing the filelist all selected entries are unselected
**
** If any LoView windows are open, pictures will be sent to the last
** opened LoView window. If no LoView windows are open then the
** pictures will be sent to a new LoView window. The argument "NEW"
** will force a new LoView window to open.
**
** Use this Program at your own risk !!!
** 
** Installation:
**
** Copy the Script to DirOpus arexx directory (DOpus:Rexx/),
** configure a Menu-item/Button/Hotkey in DirOpus and give it
** an appropriate name.
**
** Name: FilesToLoView (or what you want)
**
** Command: AREXX DOpus:Rexx/FilesToLoView.dopus
** Sends pictures to last opened window
** or a new one if none are open.
** Command: AREXX DOpus:Rexx/FilesToLoView.dopus NEW
** Sends pictures to a new LoView window.
** Flags..: No flags
*/

destdir = 'T:LoView/'
file = destdir||'ImgLst'

OPTIONS RESULTS
ADDRESS VALUE ADDRESS()

PARSE ARG option

'GetselectedFiles : -1'
files = RESULT

'Status 13 -1'
path = RESULT

IF files = 'RESULT' THEN DO
TOPTEXT "No files selected!!!"
EXIT
END

name = 'LoView0'
IF option = NEW THEN SIGNAL WriteFiles

IF EXISTS(destdir) THEN DO
SHELL COMMAND 'List >T:dopus4321 'destdir' PAT="LoView?" LFORMAT "%N"'
CALL OPEN(file,'T:dopus4321','R')
DO WHILE ~EOF(file)
temp = READLN(file)
IF temp > name THEN name = temp
END
CALL CLOSE(file)
SHELL COMMAND 'Delete >NIL: *>NIL: "T:dopus4321"'
END

WriteFiles:
IF ~EXISTS(destdir) THEN SHELL COMMAND 'Makedir 'destdir' >NIL: *>NIL:'

CALL OPEN(write,file,'w')

DO until files = ""
PARSE VAR files file ":" files
CALL WRITELN(write, path||file)
END

CALL CLOSE(write)
NONE

IF name > 'LoView0' THEN DO
ADDRESS VALUE UPPER(name)
MULTILOAD
END
ELSE
SHELL COMMAND 'Work:Viewers/LoView/LoView -multiload'
