Viewing contents of file '../idllib/contrib/lamp/sys_dep.pro'
FUNCTION sys_dep, flag, p1,p2,p3,p4
;******* *******
;**
common c_def,c_init,Lamp_Dir,LF,viewer,ziper,giftrans
os =!VERSION.OS
Vs =(BYTE(!version.release))(0) - (BYTE('0'))(0)
res=0
IF n_elements(c_init) eq 0 THEN BEGIN c_init=1 & viewer='' & Lamp_Dir='' & ziper=''
CASE os of
'MacOS': begin LF = STRING(13B) & end
; 'Win32': begin Lamp_Dir=getenv('LAMP_DIR')
; linkimage, 'winspawn',Lamp_Dir+'\cmd_WIN.so',0,'WinSpawn'
; end
ELSE:
ENDCASE
END
CASE flag of
;Add p1 to idl path
;------------------
'ADDPATH': IF strpos(!path,p1) lt 0 then BEGIN CASE os of
'vms': !path=p1+ ',' +!path
'MacOS': !path=p1+':,' +!path
'Win32': !path=p1+ ';' +!path
ELSE: !path=p1+ ':' +!path
ENDCASE
ENDIF
;After Desktop is realized or Stop
;---------------------------------
'AFTER' : BEGIN CASE os of
'Win32': if Vs eq 4 then DEVICE,main_window=0
ELSE:
ENDCASE
END
'AFTES' : BEGIN CASE os of
'Win32': if Vs eq 4 then DEVICE,main_window=1
ELSE:
ENDCASE
END
;Remove all blanks from a string exept for Mac dossiers
;------------------------------------------------------
'BLANKS' : BEGIN CASE os of
'MacOS': res=strtrim (p1,2)
ELSE: res=strcompress(p1,/remove_all)
ENDCASE
END
;Copy files in string p1 (separ. by blancs) from directory p2 to current directory
;----------------------- ------------------ ----------------- --------------------
'COPY': BEGIN CASE os of
'vms': begin
tmp=byte(strcompress(strtrim(p1,2)))
idx=where(tmp eq 32)
if idx(0) gt 0 then tmp(idx)=byte(',')
tmp=string(tmp)
cd,current=mee
if n_elements(p3) gt 0 then mee=mee+p3
spawn ,'copy/noconf '+p2+tmp+' '+mee+'*'
end
'Win32': begin
cd,current=mee
if n_elements(p3) gt 0 then mei=mee+'\'+p3 else mei=mee
cd,p2
command_line='cp '+p1+' '+mei
; winspawn, command_line
cd,mee
end
'MacOS': begin
; Get the current dir
cd, CURRENT=toFolder
; We need to use ToolServer because of the unix WildCard character (*)
Print, "SD :Copy From " + p2 + " " + p1 + " to folder " + toFolder
; NOTE : WildCard can be very very slow (2 to 5 minutes) on NFS volume mount by "MacNFS" : Don't use it !
; Translate unix WildCard (*) to ToolServer WildCard (Ć)
t1=strcompress(strtrim(p1,2))
WHILE ((( Index = STRPOS(t1, '*'))) NE -1) DO $
STRPUT, t1, 'Ć', Index
Build_ToolServerFileListFromString, p2, t1, toolServerFileList
toolServerScript = "directory " + toFolder + " ; " + $
"duplicate -y " + toolServerFileList + " : ; " + $
"setfile -t 'ZIVU' -c 'Gzip' Ć.Z"
script = [ 'tell application "' + Lamp_Dir + 'Helpers:ToolServer:ToolServer"', $
' DoScript "' + toolServerScript + '"', $
'end tell' ]
DO_APPLE_SCRIPT, script
; ToolServer ne renvoit pas de rsultat pour cette commande ?!?
res = 1
end
ELSE: begin
cd,current=mee
if n_elements(p3) gt 0 then mee=mee+'/'+p3
spawn, 'cd '+p2 + '; cp ' + p1 + ' '+mee
end
ENDCASE
END
;Delete file p1
;--------------
'DELET': BEGIN ON_IOERROR,mis_opd
CASE os of
'vms': begin OPENR ,out1,p1,/get_lun,/DELETE & FREE_LUN,out1 & end
'MacOS': begin OPENR ,out1,p1,/get_lun,/DELETE & FREE_LUN,out1 & end
'Win32': begin OPENR ,out1,p1,/get_lun,/DELETE & FREE_LUN,out1 & end
'Other': spawn,'rm -f ' +p1
ELSE: begin OPENR ,out1,p1,/get_lun,/DELETE & FREE_LUN,out1 & end
ENDCASE
mis_opd:
END
;Delete a file list p1
;------------------ --
'DELIST': BEGIN ON_IOERROR,mis_opdl
CASE os of
; 'vms': begin
; ch=p1(0)+';*' & n=n_elements(p1)
; if n gt 1 then for i=1,n-1 do ch=ch+','+p1(i)+';*'
; spawn,'delete '+ch ,/NOWAIT
; end
'vms': for i=0,n_elements(p1)-1 do begin
OPENR ,out1,p1(i) ,/get_lun,/DELETE & FREE_LUN,out1 & endfor
'MacOS': for i=0,n_elements(p1)-1 do begin
OPENR ,out1,p1(i) ,/get_lun,/DELETE & FREE_LUN,out1 & endfor
'Win32': for i=0,n_elements(p1)-1 do begin
OPENR ,out1,p1(i) ,/get_lun,/DELETE & FREE_LUN,out1 & endfor
ELSE: spawn, ['rm' ,'-f' , p1] ,/noshell
ENDCASE
mis_opdl:
END
;List current directory, return a file ascending list
;---------------------- ----------------------------
'DIR': BEGIN CASE os of
; 'vms': spawn, 'dir ',p1 ,count=p2
'vms': p1=findfile(count=p2)
'Win32': begin
;CAG - due to the redirection problem in Win32 I am using IDL
cd,current=mee
p1=FINDFILE(mee+'\*',count=p2)
end
'MacOS': begin
; NOTE : if we pass a non existent reference to the finder,
; we will end up in a "dialog with OK button" at the finder level
script = [ 'tell application "Finder"',$
' if (exists folder "' + p1 + '") then',$
' name of items in container "' + p1 + '"' + LF,$
' else',$
' set result to ""' + LF,$
' end if' + LF,$
'end tell' ]
DO_APPLE_SCRIPT, script, RESULT=p1
res = p1
p2 = n_elements(p1)
end
ELSE: spawn, 'ls ' ,p1 ,count=p2
ENDCASE
END
;List directories of current directory with modified date
;---------------- -- ----------------- ---- -------- ----
'DIRD': BEGIN CASE os of
'vms': spawn,'dir/date' +p1+ '*.dir' ,res
'Win32': p3=0 ; CAG need to be implemented
'MacOS':
ELSE: spawn,'ls -ld ' +p1+ '*' ,res
ENDCASE
END
;Return the path divider
;-----------------------
'DIVIDER': BEGIN CASE os of
'vms': res = ""
'Win32': res = "\"
'MacOS': res = ":"
ELSE: res = "/"
ENDCASE
END
; For IDL versions 4.0.1 and newer, find all label widgets
; rooted and the specified top level widget and set their
; DYNAMIC_RESIZE property.
;------------------------
'DYNLAB': IF (Vs GE 4) THEN BEGIN
IF p2 gt 0 THEN IF !version.release ne '4.0' THEN $
CASE os of
'Win32':
ELSE: dynlabel_call, p1
ENDCASE
CASE os of
'MacOS': begin if n_elements(p3) ne 1 then p3=-15
resizeButton_call, p1, p3
end
ELSE:
ENDCASE
ENDIF
;RPC modules entries (ILL use only)
;-------------------
'ENTRY': BEGIN CASE os of
'sunos': res='r_micc_'
'IRIX': res='r_micc_'
'hp-ux': res='r_micc'
ELSE: res='r_micc'
ENDCASE
END
;RPC modules (ILL use only)
;-----------
'EXEC': BEGIN CASE os of
'sunos': res=p1+'/lamp_mac/r_mic_SUN.so'
'IRIX': res=p1+'/lamp_mac/r_mic_SGI.so'
'hp-ux': res=p1+'/lamp_mac/r_mic_HP.so'
ELSE: res=''
ENDCASE
END
;EXIT from Lamp application
;--------------------------
'EXIT': BEGIN CASE os of
'MacOS': EXIT
'Win32': EXIT
ELSE: EXIT
ENDCASE
END
;Font for drawing area
;---------------------
'FONTD': BEGIN CASE os of
'vms': res='6x13bold'
'MacOS': res='Times*bold*9'
'Win32': res='arial *12'
ELSE: res='-adobe-courier-medium-r-normal--12-120-*-*-*-*-*-*'
ENDCASE
END
;Fonts for large(0) middle(1) and small(2) UIs
;---------------------------------------------
'FONTS': BEGIN
; Large UI
propor0 = '-adobe-courier-bold-r-normal--14-140-*-*-*-*-*-*'
biggest0 = '-bitstream-charter-bold-r-normal--19-180-75-75-p-119-*-*'
bigger0 = '-bitstream-charter-medium-r-normal--17-120-100-100-p-95-*-*'
b_bigger0 = '-bitstream-charter-bold-r-normal--17-120-*-*-*-*-*-*'
normal0 = '-bitstream-charter-medium-r-normal--15-140-75-75-p-84-*-*'
b_normal0 = '-bitstream-charter-bold-i-normal--15-140-75-75-p-93-*-*'
smaller0 = '-bitstream-charter-medium-r-normal--12-120-75-75-p-67-*-*'
smallest0 = '-bitstream-charter-medium-r-normal--10-100-75-75-p-56-*-*'
; Middle UI
propor1 = '-adobe-courier-bold-r-normal--14-140-*-*-*-*-*-*'
biggest1 = '-adobe-courier-bold-r-normal--14-140-*-*-*-*-*-*'
bigger1 = '-adobe-courier-medium-r-normal--14-140-*-*-*-*-*-*'
b_bigger1 = '-adobe-courier-bold-r-normal--14-140-*-*-*-*-*-*'
normal1 = '-adobe-times-medium-i-normal--14-140-*-*-*-*-*-*'
b_normal1 = '-adobe-times-bold-i-normal--14-140-*-*-*-*-*-*'
smaller1 = '-adobe-times-medium-r-normal--12-120-*-*-*-*-*-*'
smallest1 = '-adobe-times-medium-r-normal--10-100-*-*-*-*-*-*'
; Small UI
propor2 = '-adobe-courier-bold-r-normal--10-100-*-*-*-*-*-*'
biggest2 = propor2
bigger2 = '-adobe-courier-medium-r-normal--10-100-*-*-*-*-*-*'
b_bigger2 = propor2
normal2 = bigger2
b_normal2 = propor2
smaller2 = propor2
smallest2 = bigger2
res=[[propor0,biggest0,bigger0,b_bigger0,normal0,b_normal0,smaller0,smallest0],$
[propor1,biggest1,bigger1,b_bigger1,normal1,b_normal1,smaller1,smallest1],$
[propor2,biggest2,bigger2,b_bigger2,normal2,b_normal2,smaller2,smallest2]]
CASE os of
'vms': begin res(*,0)=res(*,1)
res(1,0)='-adobe-times-bold-r-normal--18-180-*-*-*-*-*-*' & end
'sunos':begin res(*,0)=res(*,1)
res(1,0)='-adobe-times-bold-r-normal--18-180-*-*-*-*-*-*' & end
'Win32':begin
propor0 = 'courier new*bold*14'
biggest0 = 'arial*bold*19'
bigger0 = 'arial *17'
b_bigger0 = 'arial*bold*17'
normal0 = 'arial *15'
b_normal0 = 'arial*bold*italic*15'
smaller0 = 'arial *12'
smallest0 = 'courier new*12'
biggest1 = 'arial*bold*15'
b_bigger1 = 'courier new*bold*16'
bigger1 = 'arial*bold*14'
propor1 = 'arial*bold*14'
normal1 = 'arial*bold*11'
b_normal1 = propor1
smaller1 = 'courier new*12'
smallest1 = smaller1
biggest2 = 'courier new*bold*16'
b_bigger2 = 'courier new*bold*16'
bigger2 = 'arial*bold*14'
propor2 = 'arial*bold*14'
normal2 = 'arial*bold*11'
b_normal2 = propor2
smaller2 = 'courier new*12'
smallest2 = smaller2
res=[[propor0,biggest0,bigger0,b_bigger0,normal0,b_normal0,smaller0,smallest0],$
[propor1,biggest1,bigger1,b_bigger1,normal1,b_normal1,smaller1,smallest1],$
[propor2,biggest2,bigger2,b_bigger2,normal2,b_normal2,smaller2,smallest2]]
end
'MacOS':begin
;biggest0 = 'times*bold*18'
;b_bigger0 = 'courier*16'
;bigger0 = 'courier*16'
;propor0 = 'courier*bold*14'
;normal0 = 'courier*14'
biggest0 = 'times*bold*17'
b_bigger0 = 'courier*15'
bigger0 = 'courier*15'
propor0 = 'courier*bold*12'
normal0 = 'courier*12'
b_normal0 = propor0
smaller0 = 'courier*12'
smallest0 = smaller0
biggest1 = 'times*bold*17'
b_bigger1 = 'courier*15'
bigger1 = 'courier*15'
propor1 = 'courier*bold*12'
normal1 = 'courier*12'
b_normal1 = propor1
smaller1 = 'courier*12'
smallest1 = 'courier new*10'
biggest2 = 'times*bold*16'
b_bigger2 = 'courier*14'
bigger2 = 'courier*14'
propor2 = 'courier*bold*12'
normal2 = 'courier*10'
b_normal2 = propor2
smaller2 = 'courier*9'
smallest2 = 'courier*8'
res=[[propor0,biggest0,bigger0,b_bigger0,normal0,b_normal0,smaller0,smallest0],$
[propor1,biggest1,bigger1,b_bigger1,normal1,b_normal1,smaller1,smallest1],$
[propor2,biggest2,bigger2,b_bigger2,normal2,b_normal2,smaller2,smallest2]]
end
ELSE:
ENDCASE
END
;Environment variable p1: 'LAMP_DIR','USER','HOST','DISPLAY'
;----------------------------------------------------------
'GETENV': BEGIN res=''
CASE os of
'MacOS': begin
if (p1 eq 'LAMP_DIR') then begin i =strpos (!path,"lamp_mac")
if i le 0 then i =strpos (!path,"lamp")+5
if i eq 4 then begin i =findfile('lamp.sav',count=nn)
if nn gt 0 then begin cd,current=res
!path=res+':,'+res+':lamp_mac:,' +!path
endif else begin
i = findfile(!Dir+ ':lamp.sav',count=nn)
if nn gt 0 then res = !Dir
endelse
endif else begin res=strmid (!path,0,i-1)
i =rstrpos( res ,",")
if i ge 0 then res=strmid ( res ,i+1,50)
i = strpos (!path,"lamp_mac")
if i lt 0 then !path=res+ ':,'+res+':lamp_mac:,' +!path
endelse
Lamp_Dir = res
endif else if (p1 eq 'USER') then begin res=""
; script =['tell application "' + Lamp_Dir + 'Helpers:ToolServer:ToolServer"'+LF,$
; 'DoScript "echo -n {user}"' + LF, $
; 'end tell' ]
; DO_APPLE_SCRIPT, script, RESULT=res
endif else if p1 eq 'HOST' then res = "" $
else if p1 eq 'LAMP_EXEC' then res = "" $
else if p1 eq 'DISPLAY' then res = ":0"
end
'Win32': if p1 eq 'LAMP_DIR' then begin i = strpos (!path,"lamp_mac")
if i le 0 then i = strpos (!path,"lamp")+5
if i eq 4 then begin i = findfile('..\lamp.sav',count=nn)
CD,current=mee
if nn gt 0 then cd,'..' $
else i = findfile( 'lamp.sav',count=nn)
if nn gt 0 then begin cd,current=res
!path=res+';'+res+'\lamp_mac;' +!path
endif else begin
i = findfile(!Dir+ '\lamp.sav',count=nn)
if nn gt 0 then res = !Dir else begin
i = findfile(!Dir+'\..\lamp.sav',count=nn)
if nn gt 0 then begin
cd,!Dir+'\..' & cd,current=res & endif
endelse
endelse
CD,mee
endif else begin res= strmid (!path,0,i-1)
i = rstrpos( res ,";")
if i ge 0 then res=strmid ( res ,i+1,50)
i = strpos (!path,"lamp_mac")
if i lt 0 then !path=!path+';'+res+';'+res+'\lamp_mac
endelse
Lamp_Dir = res
endif else res = getenv(p1)
ELSE: res = getenv(p1)
ENDCASE
END
;Make transparent gif
;--------------------
'GIFTRANS':BEGIN CASE os of
'vms':
'Win32':
'MacOS':
ELSE: begin if n_elements(giftrans) eq 0 then begin
spawn,'whereis giftrans',ret
cnt=strpos(ret,'/giftrans')
if cnt(0) lt 0 then giftrans=0 else giftrans=1
endif
if giftrans then $
spawn,'giftrans -t 0 '+P1+' > '+P1+'t; mv '+P1+'t '+P1
end
ENDCASE
END
;Used for cd,res for home directory
;----------------------------------
'HOME': BEGIN CASE os of
'vms': res='sys$login:'
'Win32': cd , current=res
'MacOS': cd , current=res
ELSE: res='~'
ENDCASE
END
;Add LAMP_DIR and LAMP_DIR/lamp_mac to idl path
;-------------------------------------------------
'IDLPATH': IF strpos(!path,p1) lt 0 then BEGIN
CASE os of
'vms': expa=expand_path('+'+strmid(p1,0,p2-1)+'.lamp_mac]')
'MacOS': expa=expand_path('+'+p1+':lamp_mac:')
'Win32': expa=expand_path('+'+p1+'\lamp_mac' )
ELSE: expa=expand_path('+'+p1+'/lamp_mac' )
ENDCASE
CASE os of
'vms': !path=!path+',' +p1+',' +strmid(p1,0,p2-1)+'.lamp_mac]'+',sys$login:'+','+expa
'MacOS':;!path=!path+',' +p1+':,'+p1+':lamp_mac:' +','+expa
'Win32':;!path=!path+';' +p1+';' +p1+'\lamp_mac' +';'+expa
ELSE: !path=!path+':' +p1+':' +p1+'/lamp_mac' +':~'+':'+expa
ENDCASE
ENDIF
;Insert a sub_dir p2 in path p1
;------------------------------
'INSUB': BEGIN CASE os of
'vms': res =strmid(p1,0,strlen(p1)-1)+ '.' +p2 +']'
'Win32': res = p1 +p2 +'\'
'MacOS': res = p1 +p2 +':'
ELSE: res = p1 +p2 +'/'
ENDCASE
END
;Get graphic function number for GXinvert
;----------------------------------------
'INVERT': BEGIN CASE os of
'vms': res=10
'Win32': res=10
'MacOS': res= 6
ELSE: res=10
ENDCASE
END
;Return machine type
;-------------------
'MACHINE': BEGIN CASE os of
'vms': res='vms'
'Win32': res='win'
'MacOS': res='mac'
ELSE: res='unix'
ENDCASE
END
;Show manual with a browser
;--------------------------
'MANUAL' : BEGIN CASE os of
'vms': begin res='mosaic_AXP.exe'
cdd=strmid(p1,0,strlen(p1)-1)+'.manual]
cd ,cdd,current=mee
spawn,'mosaic '+ 'front.htm',/NOWAIT
cd,mee
end
'Win32': begin res=''
command_line=getenv('netscape')
if(command_line ne '') then begin
res='Netscape'
manual=p1+'\manual\front.htm'
id=findfile(manual,count=cnt)
if cnt gt 0 then command_line=command_line+' '+manual $
else command_line=command_line+ $
' http://www.ill.fr/data_treat/lamp/front.html'
; winspawn, command_line
endif
end
'MacOS': begin
res='MOSS' ; signature de l'application "NetScape"
commd = p1+':manual:front.htm'
id=findfile(commd,count=cnt)
if cnt gt 0 then spawn, MACCREATOR='MOSS', commd
; We could use AppleScript to open the URL...
; ' http://www.ill.fr/data_treat/lamp/front.htm '
end
ELSE: begin res=''
ic='netscape'
spawn,'whereis netscape',ret
cnt=strpos(ret,'/netscape')
if cnt(0) lt 0 then begin
spawn,'whereis mosaic',ret
cnt=strpos(ret,'/mosaic')
if cnt(0) ge 0 then ic ='mosaic'
cnt=[0]
endif
if cnt(0) ge 0 then begin
if strpos(ic,'netscape') ge 0 then ic=ic+' -install'
commd =p1+'/manual/front.htm'
id=findfile(commd,count=cnt)
if cnt gt 0 then spawn ,ic + ' ' + commd + ' &' $
else spawn ,ic + ' http://www.ill.fr/data_treat/lamp/front.htm &'
res=ic
endif
end
ENDCASE
END
;MAP or not MAP (some devices have problems to add widgets after realizing-> res=1)
;--------------
'MAP': BEGIN CASE os of
'MacOS': res=1
'Win32': IF !version.release lt '5.1' THEN res=1
ELSE: res=0
ENDCASE
IF !version.release lt '3.6' THEN res=-1
IF res eq 0 THEN $
IF (Vs GE 4) THEN $
IF !version.release ne '4.0' THEN res=2
END
;Create a directory
;------------------
'MKDIR': BEGIN CASE os of
'vms': spawn,'create/dir ' +p1
'MacOS': begin
; D'abord, verifier si c'est possible
ii=findfile(p1,count=cnt)
; Si le dossier existe deja, on sort
if (cnt gt 0) then return, res
FileStart = RSTRPOS(p1, ':')+1
container = STRMID(p1,0,FileStart)
folderName = STRMID(p1, FileStart, 1000)
script = [ 'tell application "Finder"', $
' if not (exists folder "' + p1 + '") then', $
' make new folder at container "' + container + '" with properties {name:"' + folderName + '"}' + LF, $
' end if' + LF, $
'end tell' ]
DO_APPLE_SCRIPT, script
res=1
end
'Win32': begin
command_line='mkdir '+p1
; winspawn, command_line
end
ELSE: spawn,'mkdir ' +p1
ENDCASE
END
;Return /home/sub_dir
;--------------------
'NEWDIR': BEGIN CASE os of
'vms': res = '[' +p1+ '.' +p2 +']'
'Win32': res = '..'+ '\' +p2
'MacOS': res = p1+ ':' +p2
ELSE: res = '~' +p1+ '/' +p2
ENDCASE
END
;Return path/sub_dir/
;---------------------
'NEWSUB': BEGIN CASE os of
'vms': res =strmid(p1,0,strlen(p1)-1)+ '.' +p2 +']'
'Win32': res = p1+ '\' +p2 +'\'
'MacOS': res = p1+ ':' +p2 +':'
ELSE: res = p1+ '/' +p2 +'/'
ENDCASE
END
;Start player p1 file_path is p2/p3
;----------------------------------
'PLAY_ON': BEGIN CASE os of
'vms': begin p4=0
spawn, 'playaifc '+p2+p3,/NOWAIT
end
'Win32': p4=0 ;CAG I haven't got a sound card
'MacOS': begin
script = [ 'tell application "' + Lamp_Dir + 'Helpers:SoundMachine 2.1"', $
' open file "' + p2 + ':' + p3 + '"' + LF, $
'end tell' ]
DO_APPLE_SCRIPT, script
p4=0
res=1
end
ELSE: spawn, p1+p2+'/'+p3+' &' ,PID=p4
ENDCASE
END
;Kill player
;-----------
'PLAY_OF': BEGIN CASE os of
'vms':
'Win32':
'MacOS': begin
script = [ 'tell application "' + Lamp_Dir + 'Helpers:SoundMachine 2.1"', $
' quit', $
'end tell' ]
DO_APPLE_SCRIPT, script
res=1
end
ELSE: spawn, ['kill' , string(p4)] ,/noshell
ENDCASE
END
;return "path_for_player"
;------------------------
'PLAYER': BEGIN CASE os of
'vms': res=getenv('playaifc')
'Win32': res=''
'MacOS': res='' ;res='SoundMachine 2.1'
'IRIX': begin res=''
spawn,'whereis playaifc',str
if strpos(str(0),'/playaifc') gt 0 then res='playaifc -rq '
end
ELSE: res=getenv('playaifc')
ENDCASE
END
;File extension fs problems (vms)
;--------------------------
'POT': BEGIN CASE os of
'vms': p1=p1+'.'
ELSE:
ENDCASE
END
'POT+': BEGIN CASE os of
'vms':begin
j = STRPOS(p1, '.;')
if j gt 0 then p1=STRMID(p1,0,j)+p2+'.' $
else begin
if p3 eq 1 then begin
j =STRPOS(p1, ';')
if j gt 0 then p1=STRMID(p1,0,j)+p2 else p1=p1+p2
endif else begin
j =STRPOS(p1, '.')
if j gt 0 then p1=STRMID(p1,0,j+1)+p2
endelse
endelse
end
ELSE:p1=p1+p2
ENDCASE
END
;Print a PS file p2 to a specified printer_name p1
;-------------------------------------------------
'PRINT': BEGIN CASE os of
'vms': spawn,'print/notify/queue='+p1+' '+p2
'Win32': DEVICE,print_file=p2
'MacOS':begin
;;Do you really want to choose a printer ???
;script = [ 'tell application "Finder"',$
; 'print file "' + p2 + '"' ,$
; 'end tell' ]
;DO_APPLE_SCRIPT, script, RESULT=res
;HANSEN!!
lf=STRING(13B)
CD,CURRENT=current_directory
p3=current_directory+p2
PRINT,'print ',p3,' on ', p1
script=['tell application "Finder"'+lf+'copy file "'+p3+'" to item "'+p1+'"'+lf+'end tell']
PRINT,script
DO_APPLE_SCRIPT, script;, RESULT=res
end
ELSE: begin
if strpos(p2,'_s.') gt 0 then print,'lp -c -d'+p1+' '+p2 $
else print,'lp -d' +p1+' '+p2
if strpos(p2,'_s.') gt 0 then spawn,'lp -c -d'+p1+' '+p2 $
else spawn,'lp -d' +p1+' '+p2
end
ENDCASE
END
;Print a file p1 to the default printer
;--------------------------------------
'PRT_DEF': BEGIN CASE os of
'vms': spawn,'print '+p1
'Win32': ;CAG - This too is proving tricky
'MacOS':begin
;script = [ 'tell application "Finder"', $
; 'print file "' + p1 +'"' , $
; 'end tell' ]
;DO_APPLE_SCRIPT, script, RESULT=res
;HANSEN!!
lf=STRING(13B)
CD,CURRENT=current_directory
p3=current_directory+p1
PRINT,'print ', p3
script = ['tell application "Finder"'+lf+'print file "'+p3+'"'+lf+'end tell']
PRINT,script
DO_APPLE_SCRIPT, script, RESULT=res
end
ELSE: spawn,'lp ' +p1
ENDCASE
END
;Color: type of visual
;---------------------
'PSEUDO': BEGIN CASE os of
'Win32': device, decomposed = 0
ELSE: device, pseudo_color = 8
ENDCASE
END
;Byte Order compatibility
;------------------------
'SWAPER': BEGIN CASE os of
'vms': if (p1 eq 'uni') or (p1 eq 'mac') then res=1
'Win32': if (p1 eq 'uni') or (p1 eq 'mac') then res=1
'MacOS': if (p1 eq 'vms') or (p1 eq 'win') then res=1
ELSE: if (p1 eq 'vms') or (p1 eq 'win') then res=1
ENDCASE
END
;Zip file p1
;-------- --
'ZIP': BEGIN CASE os of
'vms': res=0
'Win32': res=0
'MacOS': res=0
ELSE: begin if ziper eq '' then begin
spawn,'whereis zip',str
if strpos(str(0),'/zip') gt 0 then ziper='zip' else ziper='-'
endif
res=1
if ziper ne '-' then begin
fzip=strmid(p1,0,strpos(p1,'.'))
if p2 ne '' then spawn, 'cd '+p2+' ; zip -mq ' +fzip+' ' +p1
if p2 eq '' then spawn, 'zip -mq ' +fzip+' ' +p1
endif else res=0
end
ENDCASE
END
;UnZip file p1
;---------- --
'UNZIP': BEGIN CASE os of
'vms': res=0
'Win32': res=0
'MacOS': res=0
ELSE: begin if ziper eq '' then begin
spawn,'whereis unzip',str
if strpos(str(0),'/unzip') gt 0 then ziper='zip' else ziper='-'
endif
res=1
if ziper ne '-' then spawn, 'cd '+p2+' ; unzip -qqux ' +p1 else res=0
end
ENDCASE
END
;Compress file p1
;-------- ---- --
'DO_Z': BEGIN CASE os of
'vms': begin
spawn, 'compress -f '+p1
spawn, 'rename '+p1+'_Z '+p1+'Z' ,/NOWAIT
end
'Win32': begin
command_line='gzip -fq '+p1
; winspawn,command_line
end
'MacOS':
ELSE: spawn, 'compress -f ' +p1
ENDCASE
END
;UnCompress file p1
;---------- -------
'UN_Z': BEGIN CASE os of
'vms': spawn, 'gunzip -dfq '+p1
'Win32': begin
command_line='gzip -dfq '+p1 ;relies on gzip.exe being in the path
; winspawn, command_line
end
'MacOS':begin
; 'LZIV' = signature de l'application "MacCompress3.2"
; spawn, MACCREATOR='LZIV', p1
script = [ 'tell application "' + Lamp_Dir + 'Helpers:MacGzip„PPC"',$
' open file "' + p1 + '"',$
'end tell' ]
DO_APPLE_SCRIPT, script
; MacGzip works in the background
; so we need to wait for the uncompressed files
uncompressedFile = STRMID(p1, 0, STRLEN(p1)-2) ; Strip ".Z" suffixe
dummy = FindFile(uncompressedFile, Count=AreYouThere)
WHILE (AreYouThere EQ 0) DO BEGIN
Print, "Waiting..."
Wait, 0.5
dummy = FindFile(uncompressedFile, Count=AreYouThere)
ENDWHILE
res=1
end
ELSE: spawn, 'uncompress -f ' +p1
ENDCASE
END
;UnCompress file list p1
;---------- ------------
'UN_ZLIS': BEGIN CASE os of
'vms': BEGIN
ch=p1(0) & n=n_elements(p1)-1
if n gt 0 then for i=1,n do ch=ch+' '+p1(i)
spawn, 'gunzip -dfq '+ch
END
'Win32': begin
command_line='gzip -dfq'
for i=0,n_elements(p1)-1 do command_line=command_line+' '+p1(i)
; winspawn, command_line
end
'MacOS':begin
; Get the current dir
cd, CURRENT=homeFolder
; Add path
fileArray = homeFolder + p1
lastFile = fileArray(n_elements(fileArray)-1)
; Prepare the file list in AppleScript format
Build_MacFileListFromArray, fileArray ,macFileList
; Print, "SD :UN_ZLIS :" + macFileList
script = [ 'tell application "' + Lamp_Dir + 'Helpers:MacGzip„PPC"',$
' open ' + macFileList + LF,$
'end tell' ]
; Print, "Quitting IDL..."
DO_APPLE_SCRIPT, script
; Print, "Returning..."
; MacGzip works in the background
; so we need to wait for the last uncompressed file
lastFile = STRMID(lastFile, 0, STRLEN(lastFile)-2) ; Strip ".Z" suffixe
dummy = FindFile(lastFile, Count=AreYouThere)
WHILE (AreYouThere EQ 0) DO BEGIN
Print, "Waiting..."
Wait, 0.5
dummy = FindFile(lastFile, Count=AreYouThere)
ENDWHILE
; Print, "OK"
res=1
end
ELSE: spawn,['uncompress','-f',p1],/noshell
ENDCASE
END
'DEMO': if float(!version.release) ge 5.1 then ii=execute('res=LMGR(/DEMO)<1') else res=0
'STUDENT': if float(!version.release) ge 5.1 then ii=execute('res=LMGR(/STUDENT)<1') else res=0
'RUNTIME': if float(!version.release) ge 5.1 then ii=execute('res=LMGR(/RUNTIME)<1') else res=0
'EMBEDDED': if float(!version.release) ge 5.1 then ii=execute('res=LMGR(/EMBEDDED)<1') else res=0
'VERSION': res=float(!version.release)
;Start a VIEWER (vrml file is lamp.wrl)
;--------------------------------------
'VIEWER': BEGIN CASE os of
'vms': begin if viewer eq '' then begin
viewer=getenv('VrmlViewer')
if viewer eq '' then begin viewer='-'
print,string(7b)+'(no logical VrmlViewer) !!!' & endif
endif
res=1
if viewer ne '-' then begin
if n_elements(p1) eq 1 then spawn,'VrmlViewer '+p1,/NOWAIT
endif
end
'Win32':res=1
'MacOS':res=1
ELSE: begin if viewer eq '' then begin
spawn,'whereis webspace',str
if strpos(str(0),'/webspace') gt 0 then viewer='webspace -remote ' $
else begin spawn,'whereis modelviewer',str
if strpos(str(0),'/modelvie') gt 0 then viewer='modelviewer -remote ' $
else begin spawn,'whereis vrweb',str
if strpos(str(0),'/vrweb') gt 0 then viewer='vrweb -remote ' $
else begin spawn,'whereis ivview',str
if strpos(str(0),'/ivview') gt 0 then viewer='ivview '
endelse & endelse & endelse
if viewer eq '' then viewer=getenv('VrmlViewer')
if viewer eq '' then begin viewer='-'
print,string(7b)+'(webspace,modelviewer,vrweb,VrmlViewer) not found !!!' & endif
endif
res=1
if viewer ne '-' then begin
if n_elements(p1) eq 1 then spawn,viewer+' '+p1+' &'
endif
end
ENDCASE
END
ELSE:
ENDCASE
RETURN,res
END ; sys_dep
PRO Build_MacFileListFromArray ,file_array ,macFile_List
;** **************************
;**
; Entree : ['toto', 'tata', 'titi'] (IDL Array)
; Sortie : "{file toto, file tata, file titi} String
macFile_List = ''
FOR Index=0,n_elements(file_array)-1 DO BEGIN
IF (INDEX EQ 0) THEN $
macFile_List = 'file "' + file_array(Index) + '"' $
ELSE $
macFile_List = macFile_List + ', file "' + file_array(Index) + '"'
END
macFile_List = '{' + macFile_List + '}'
return
END ; Build_MacFileListFromArray
PRO Build_MacFileListFromString ,file_list ,macFile_List
;** ***************************
;**
; Entree : "toto tata titi" String
; Sortie : "{file toto, file tata, file titi} String
fileArray = str_sep(file_list, ' ') ; Found in IDL Lib
Build_MacFileListFromArray, fileArray ,macFile_List
return
END ; Build_MacFileListFromString
PRO Build_ToolServerFileListFromString, sourceFolder, file_list, toolServer_List
;** **********************************
;**
; Entree : 'sourceFolder' 'toto tata titi' String
; Sortie : '\"sourceFolder:toto\" \"sourceFolder:tata\" \"sourceFolder:titi\"' String
fileArray = str_sep(file_list, ' ') ; Found in IDL Lib
toolServer_List = ''
FOR Index=0,n_elements(fileArray)-1 DO BEGIN
toolServer_List = toolServer_List + '\"' + sourceFolder + fileArray(Index) + '\" '
END
return
END ; Build_ToolServerFileListFromString