/usr/share/gnudatalanguage/astrolib/textopen.pro is in gdl-astrolib 2018.02.16+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | PRO TEXTOPEN,PROGRAM,TEXTOUT=TEXTOUT, STDOUT = STDOUT, MORE_SET = more_set, $
SILENT = silent, WIDTH = width
;+
; NAME:
; TEXTOPEN
; PURPOSE:
; Open a device specified by TEXTOUT with unit !TEXTUNIT
; EXPLANATION:
; Procedure to open file for text output. The type of output
; device (disk file or terminal screen) is specified by the
; TEXTOUT keyword or the (nonstandard) system variable !TEXTOUT.
;
; CALLING SEQUENCE:
; textopen, program, [ TEXTOUT =, /STDOUT, /SILENT, MORE_SET=, WIDTH= ]
;
; INPUTS:
; program - scalar string giving name of program calling textopen
;
; OPTIONAL INPUT KEYWORDS:
; TEXTOUT - Integer scalar (0-7) specifying output file/device to be
; opened (see below) or scalar string giving name of output file.
; If TEXTOUT is not supplied, then the (non-standard) system
; variable !TEXTOUT is used.
; /SILENT - By default, TEXTOPEN prints an informational message when
; opening a file for hardcopy output. Set /SILENT (or !QUIET)
; to suppress this message.
; /STDOUT - if this keyword is set and non-zero, then the standard output
; (unit = -1) is used for TEXTOUT=1 or TEXTOUT=2. The use
; of STDOUT has 2 possible advantages:
; (1) the output will appear in a journal file
; (2) Many Unix machines print spurious control characters when
; printing to /dev/tty. These characters are eliminated by
; setting /STDOUT
;
; The disadvantage of /STDOUT is that the /MORE option is not
; available.
;
; WIDTH - Specify line width for hardcopy output line wrapping (passed onto OPENW).
;
; OPTIONAL OUTPUT KEYWORD:
; MORE_SET - Returns 1 if the output unit was opened with /MORE. This
; occurs if (1) TEXTOUT = 1 and (2) the device is a tty, and
; (3) /STDOUT is not set. User can use the returned value
; of MORE_SET to determine whether to end output when user
; presses 'Q'.
; SIDE EFFECTS:
; The following dev/file is opened for output. Different effects
; occur depending whether the standard output is a GUI (Macintosh,
; Windows, Unix/IDLTool) or a TTY
;
; textout=0 Nowhere
; textout=1 if a TTY then TERMINAL using /more option
; otherwise standard (Unit=-1) output
; textout=2 if a TTY then TERMINAL without /more option
; otherwise standard (Unit=-1) output
; textout=3 <program>.prt
; textout=4 laser.tmp
; textout=5 user must open file
; textout=7 same as 3 but text is appended to <program>.prt
; file if it already exists.
; textout = filename (default extension of .prt)
;
; The unit to be opened is obtained with the procedure GET_LUN
; unless !TEXTOUT=5. The unit number is placed in system variable
; !TEXTUNIT. For !TEXTOUT=5 the user must set !TEXTUNIT to the
; appropriate unit number.
;
; NOTES:
; When printing to a TTY terminal, the output will *not* appear in an
; IDL JOURNAL session, unlike text printed with the PRINT command.
;
; NON-STANDARD SYSTEM VARIABLES:
; TEXTOPEN will automatically define the following system variables if
; they are not previously defined:
;
; DEFSYSV,'!TEXTOUT',1
; DEFSYSV,'!TEXTUNIT',0
; HISTORY:
; D. Lindler Dec. 1986
; Keyword textout added, J. Isensee, July, 1990
; Made transportable, D. Neill, April, 1991
; Trim input PROGRAM string W. Landsman Feb 1993
; Don't modify TEXTOUT value W. Landsman Aug 1993
; Modified for MacOS I. Freedman April 1994
; Modified for output terminals without a TTY W. Landsman August 1995
; Added /STDOUT keyword W. Landsman April 1996
; added textout=7 option, D. Lindler, July, 1996
; Exit with RETURN instead of RETALL W. Landsman June 1999
; In IDL V5.4 filepath(/TERMINAL) not allowed in the IDLDE WL August 2001
; Added MORE_SET output keyword W.Landsman January 2002
; Added /SILENT keyword W. Landsman June 2002
; Define !TEXTOUT and !TEXTUNIT if needed. R. Sterner, 2002 Aug 27
; Return Calling Sequence if no parameters supplied W.Landsman Nov 2002
; Remove VMS specific code W. Landsman Sep 2006
; Make sure MORE_SET is always defined W. Landsman Jan 2007
; Added WIDTH keyword J. Bailin Nov 2010
; Use V6.0 notation W. Landsman April 2011
;-
;-----------------------------------------------------------
On_Error,2
compile_opt idl2
if N_params() LT 1 then begin
print,'Syntax - TEXTOPEN, program, [ TEXTOUT =, /STDOUT, /SILENT,'
print,' MORE_SET=, WIDTH= ]'
return
endif
defsysv,'!TEXTOUT',exists=ex ; Check if !TEXTOUT exists.
if ex eq 0 then defsysv,'!TEXTOUT',1 ; If not define it.
defsysv,'!TEXTUNIT',exists=ex ; Check if !TEXTUNIT exists.
if ex eq 0 then defsysv,'!TEXTUNIT',0 ; If not define it.
more_set = 0
;
; Open proper unit.
;
if N_elements( textout ) NE 1 then textout = !textout ;use default output dev.
; keywords for openw
if n_elements(width) gt 0 then openw_keywords = {width: width}
if size(textout,/tname) EQ 'STRING' then begin ;test if filename entered
filename = textout
j = strpos(filename,'.') ;test if file extension given
if j lt 0 then filename = filename + ".prt"
text_out = 6
endif else text_out = textout
if TEXT_OUT eq 5 then begin
if !TEXTUNIT eq 0 then begin
print,' '
print,' You must set !TEXTUNIT to the desired unit number...'
print,' ...see following example'
print,' '
print,' OPENW, LUN, filename, /GET_LUN
print,' !TEXTUNIT = LUN
print,' DBPRINT...
print,'
print,' Action: returning'
print,' '
return
end
return
end
stndout = fstat(-1)
isatty = (stndout.isatty) && (~stndout.isagui) && $
(~keyword_set(STDOUT))
if isatty || (text_out GT 2) then begin
if !TEXTUNIT GT 0 then free_lun,!TEXTUNIT
get_lun,unit
!TEXTUNIT = unit
endif else !TEXTUNIT = -1 ;standard output
more_set = (text_out EQ 1) && isatty
case text_out of
1: if isatty then openw, !TEXTUNIT, filepath(/TERMINAL), /MORE, _extra=openw_keywords
2: if isatty then openw, !TEXTUNIT, filepath(/TERMINAL) , _extra=openw_keywords
3: begin
oname = strlowcase( strtrim( PROGRAM,2) +'.prt')
openw, !TEXTUNIT, oname, _extra=openw_keywords
if ~keyword_set(SILENT) then $
message,'Output is being directed to a file ' + oname,/INFORM
end
4: openw, !TEXTUNIT, 'laser.tmp', _extra=openw_keywords
6: begin
openw,!TEXTUNIT,filename, _extra=openw_keywords
if ~keyword_set(SILENT) then $
message,'Output is being directed to a file ' + filename,/INFORM
end
7: begin
oname = strlowcase(strtrim( PROGRAM,2) +'.prt')
openw, !TEXTUNIT, oname, /append, _extra=openw_keywords
if ~keyword_set(SILENT) then $
message,'Output is being appended to file ' + oname,/INFORM
for i=0,3 do printf,!textunit,' ' ;added a couple of blank lines
end
0: openw,!TEXTUNIT, strtrim(PROGRAM,2) + '.tmp',/DELETE, _extra=openw_keywords
else: begin
!textunit = 0
print,' '
print,' Invalid value for TEXTOUT =',TEXTOUT
print,' '
print,' ...the possibilities are:
print,' '
print,' textout=0 nowhere
if isatty then begin
print,' textout=1 terminal with /more
print,' textout=2 terminal without /more
endif else begin
print,' textout=1 terminal
print,' textout=2 terminal
endelse
print,' textout=3 file <program>.prt
print,' textout=4 file laser.tmp
print,' textout=5 User supplied file
print,' textout = filename (default extension of .prt)
print,' textout=7 Same as 3 but append the file
print,' '
print,' Action: returning
print,' '
return
end
endcase
return
end ; textout
|