forked from kodamail/gscript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathallclose.gs
47 lines (42 loc) · 799 Bytes
/
allclose.gs
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
*
* Help is in the end of this script.
*
function allclose( args )
_version='0.01r1'
* if( args = '' )
* help()
* return
* endif
* serach for the largest file number
'q files'
i = 1
fmax = 0
while( 1 )
line = sublin( result, i )
if( line = '' ) ; break ; endif
num = subwrd( line, 2 )
if( num = fmax + 1 ) ; fmax = fmax + 1 ; endif
i = i + 1
endwhile
* close
say 'closing 'fmax' files'
f = fmax
while( f >= 1 )
'close 'f
f = f - 1
endwhile
return
*
* help
*
function help()
say ' Name:'
say ' allclose '_version' - close all the opened files'
say ' '
say ' Usage:'
say ' allclose'
say ''
say ' Copyright (C) 2010 Chihiro Kodama'
say ' Distributed under GNU GPL (http://www.gnu.org/licenses/gpl.html)'
say ''
return