home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 17
/
CD_ASCQ_17_101194.iso
/
vrac
/
ensmgr14.zip
/
ENS_MGRA.SCR
< prev
next >
Wrap
Text File
|
1994-07-24
|
22KB
|
797 lines
; Terry Gildea [70511,2530] FILE: ENS_MGRA.SCR
;
; OFFLINE portion of ENS management scripts; requires ens_mgrz.scr.
; Copyright (c) 1994 Terry L Gildea Free redistribution authorized
;
; Edit fields between * * * lines before EACH running of script!!
;
; +++keyword-flag+++ " %v %d" Requires OzCIS ver 2.0c(1)
; Version " 1:4 24-Jul-94"
; * * * * * * * * * * * * * * * * * * * * * * *
; name of existing folder to be Deleted
define $DelName ""
; name of existing folder to be Changed
define $ChgName ""
; name folder to Create; OR new name for existing folder
define $NewName ""
; expiration date in MM/DD/YY format
define $expire ""
; number of days to retain clipped stories; max is 14
define $retain ""
; wire services to add-ascending order, e.g. 5,19
define $AddWire ""
; wire services to delete-ascending order, e.g. 2,11
define $DelWire ""
; key phrases to delete-decending order, e.g. 5,2
define $DelKey ""
; up to seven new/changed alphabetized key phrases
define $key1 ""
define $key2 ""
define $key3 ""
define $key4 ""
define $key5 ""
define $key6 ""
define $key7 ""
; * * * * * * * * * * * * * * * * * * * * * * *
;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
; CONFIGURATION OPTIONS; SEE DOCUMENTATION FOR DETAILS
; The variable $path MUST be the same in BOTH scripts!
define $path ""
define $logfile "ens_mgra.log"
;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
; THESE CONSTANTS MAY BE CHANGED BY COMPUSERVE IN THE FUTURE
define #BrkWire 18
define #MaxWire 23
define #MaxKey 7
define #MaxRetain 14
define #MaxName 10
define #MaxFldrs 3
;= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
; ENS_MGRA.SCR Page 1 of 13
define #debug %false
;define #debug %true
define #maxDays
define #moNbr
define $moName
define #expire_month
define #expire_day
define #expire_year
define #current_month
define #current_day
define #current_year
define #LoChgdKey
define #HiChgdKey
define $filename
define $name
define $key
define $error
define $select
define #parentotl
timeout 0
onerror parse_error
statline "Executing script ENS_MGR.SCR (c) 1994"
; make sure user input strings are ok.
upcase $DelName
trim $DelName
upcase $NewName
trim $NewName
upcase $ChgName
trim $ChgName
upcase $expire
trim $expire
upcase $retain
trim $retain
upcase $AddWire
trim $AddWire
upcase $DelWire
trim $DelWire
upcase $DelKey
trim $DelKey
upcase $key1
trim $key1
upcase $key2
trim $key2
upcase $key3
trim $key3
upcase $key4
trim $key4
upcase $key5
trim $key5
upcase $key6
trim $key6
upcase $key7
trim $key7
; Page 2 of 13 ENS_MGRA.SCR
; find highest/lowest numbered key phrase change entered above
set #HiChgdKey 0
set #LoChgdKey 0
if $key1 != "" set #HiChgdKey 1
if $key7 != "" set #LoChgdKey #MaxKey
if $key2 != "" set #HiChgdKey 2
if $key6 != "" set #LoChgdKey 6
if $key3 != "" set #HiChgdKey 3
if $key5 != "" set #LoChgdKey 5
if $key4 != "" set #HiChgdKey 4
if $key4 != "" set #LoChgdKey 4
if $key5 != "" set #HiChgdKey 5
if $key3 != "" set #LoChgdKey 3
if $key6 != "" set #HiChgdKey 6
if $key2 != "" set #LoChgdKey 2
if $key7 != "" set #HiChgdKey #MaxKey
if $key1 != "" set #LoChgdKey 1
; perform check on data validity
gosub valid_name
set #1 1
set $select $retain
if $retain != "" val #1 $retain
if #1 > #MaxRetain set $error "Maximum retention of 14 days."
if #1 < 1 set $error "Retention period must be 1-14 days."
if $error != "" goto ckErr
if $expire != "" gosub valid_date
if $error != "" goto ckErr
if $DelKey != "" gosub valid_phrase
if $error != "" goto ckErr
set $8 $AddWire
if $AddWire != "" gosub valid_wire
if $error != "" goto ckErr
set $8 $DelWire
if $DelWire != "" gosub valid_wire
if $error != "" goto ckErr
if $DelName != "" goto ckChg
if $ChgName != "" goto ckChg
if $NewName != "" goto ckNew
set $error "You MUST name a folder in one of Del/New/Chg fields."
goto ckErr
ckChg:
if $ChgName = "" goto ckNew
set $error "Can't change a folder after deleting it."
if $ChgName = $DelName goto ckErr
set $error "New name can't be same as Chg name."
if $NewName = $ChgName goto ckErr
set $error "Chg option must specify at least one field to change."
if $NewName != "" set $error ""
if $expire != "" set $error ""
if $retain != "" set $error ""
if $AddWire != $DelWire set $error ""
if $DelKey != "" set $error ""
if #HiChgdKey > 0 set $error ""
goto ckErr
; ENS_MGRA.SCR Page 3 of 13
ckNew:
set $error ""
if $NewName = "" goto ckErr
if $NewName = $ChgName set $error "New name can't equal Chg name."
if $NewName = "" goto ckErr
if $expire = "" set $error "New folder must have expiration date."
if $retain = "" set $error "New folder must have retention period."
if $DelWire != "" set $error "Can't delete wires from a new folder."
if $DelKey != "" set $error "Can't delete phrases from new folder."
if $AddWire = "" set $error "New folder must specify wires to scan."
if #HiChgdKey = 0 set $error "New folder must specify a key phrase."
ckErr:
if $error = "" gosub valid_paren
; Give the user one last chance
cls
if $error = "" gosub get_old
if $DelName != "" writeln "DEL: " $DelName
if $ChgName != "" writeln "CHG: " $ChgName
if $NewName != "" writeln "NEW: " $NewName
if $expire != "" writeln "EXPIRE: " $expire
if $retain != "" writeln "RETAIN: " $retain
if $DelWire != "" writeln "DEL-WIRES: " $DelWire
if $AddWire != "" writeln "ADD-WIRES: " $AddWire
if $DelKey != "" writeln "DEL-KEYS: " $DelKey
if #LoChgdKey != 0 writeln "NEW/CHG KEYS:"
if $key1 != "" writeln "1. " $key1
if $key2 != "" writeln "2. " $key2
if $key3 != "" writeln "3. " $key3
if $key4 != "" writeln "4. " $key4
if $key5 != "" writeln "5. " $key5
if $key6 != "" writeln "6. " $key6
if $key7 != "" writeln "7. " $key7
writeln
if $error != "" writeln "ERROR: " $error
offline:
set $5 "N"
set $4 "Correct ERRORS before going online. PRESS RETURN"
if $error = "" set $4 "Save these data for online processing? (Y/N)"
prompt $5 $4
if $error != "" goto alldone
upcase $5
if $5 = "Y" gosub write_result
goto alldone
alldone:
capture ON $logfile /o
gosub record_data
cwrite "Normal script termination offline. " %date " " %time
capture OFF
end
; Page 4 of 13 ENS_MGRA.SCR
file_error:
capture ON $logfile /o
writeln "File ERROR " " on: " $filename " " $error
cwrite "File ERROR " " on: " $filename " " $error
capture OFF
fail
parse_error:
capture ON $logfile /o
writeln "ERROR parsing: " $1 " at " $select " " #3
cwrite "ERROR parsing: " $1 " at " $select " " #3
gosub record_data
capture OFF
fail
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Subroutine to record the values of input data
;
record_data:
if $DelName != "" cwrite "DEL: " $DelName
if $ChgName != "" cwrite "CHG: " $ChgName
if $NewName != "" cwrite "NEW: " $NewName
if $expire != "" cwrite "EXPIRE: " $expire
if $retain != "" cwrite "RETAIN: " $retain
if $DelWire != "" cwrite "DEL-WIRES: " $DelWire
if $AddWire != "" cwrite "ADD-WIRES: " $AddWire
if $DelKey != "" cwrite "DEL-KEYS: " $DelKey
if #LoChgdKey != 0 cwrite "NEW/CHG KEYS:"
if $key1 != "" cwrite "1. " $key1
if $key2 != "" cwrite "2. " $key2
if $key3 != "" cwrite "3. " $key3
if $key4 != "" cwrite "4. " $key4
if $key5 != "" cwrite "5. " $key5
if $key6 != "" cwrite "6. " $key6
if $key7 != "" cwrite "7. " $key7
cwrite %cr
if $error != "" cwrite "ERROR: " $error %cr
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; ENS_MGRA.SCR Page 5 of 13
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Subroutine to check for valid expiration date
; Parameters: $expire - the expiration date
; Returns: $error - error message (null if no error)
;
valid_date:
set $error "Date needs leading zero or delimiter. Use MM/DD/YY."
length #9 $expire
if #9 != 8 return
set $error "Invalid delimiter in date. Use MM/DD/YY format."
pos #9 "/" $expire
if #9 != 3 return
set $9 $expire
delstr $9 1 3 $8
midstr $9 1 2
pos #9 "/" $8
if #9 != 3 return
val #9 $9
set $error "Month can't exceed 12. Use MM/DD/YY format."
if #9 > 12 return
set $error ""
gosub valid_days
if $error != "" return
set $error ""
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Subroutine to check for valid input data in list of DelPhrase
; Parameters: $DelKey - list of phrase numbers to be deleted
; #4 - integer value of parsed number
; Returns: $error - error message (null if no error)
;
valid_phrase:
set #8 #MaxKey
set $1 $DelKey
vp_loop:
gosub parse
set $error "Highest possible del-key is only " #MaxKey
if #4 > #MaxKey goto end_vp
set $error "Deleted phrases MUST be listed in decending order."
if #4 > #8 goto end_vp
set #8 #4
if #3 != 0 goto vp_loop
set $error ""
end_vp:
return
; Page 6 of 13 ENS_MGRA.SCR
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Subroutine to check for valid input data in DelWire and AddWire
; Parameters: $8 - either $DelWire or $AddWire
; #4 - integer value of parsed number
; Returns: $error - error message (null if no error)
;
valid_wire:
set #8 0
set $1 $8
if $error != "" goto end_vw
vw_loop:
gosub parse
set $error "Wire add/del MUST be listed in ascending order."
if #4 < #8 goto end_vw
set $error "No wire service exists beyond " #MaxWire
if #4 > #MaxWire goto end_vw
set #8 #4
if #3 != 0 goto vw_loop
set $error ""
end_vw:
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Subroutine to extract numbers from sequence in string variable
; Parameters: $1 - string containing the remaining sequence
; Returns: $select - string representation of next digits
; #4 - integer representation of the number
; #3 - equals 0 when no more numbers remain
;
parse:
; locate delimiter char in sequence of numbers
pos #1 "," $1
set #3 #1
set $select $1
; if zero this is last number
if #1 = 0 goto last_one
if #debug = %true cwrite %cr "Remaining parse of: " $1
; extract number from the input sequence
dec #1
midstr $1 1 #1 $select
; delete current number from the string
inc #1
delstr $1 1 #1
; check for error, a non-digit string
last_one:
val #4 $select
if #debug = %true cwrite "Returning from parse with # " $select
return
; ENS_MGRA.SCR Page 7 of 13
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Subroutine to call check routine for each name string
; Parameters: $ChgName, $DelName, $NewName
; Returns: $error - error message (null if no error)
;
valid_name:
set $name $NewName
gosub ck_name
set $name $ChgName
if $error = "" gosub ck_name
set $name $DelName
if $error = "" gosub ck_name
return
ck_name:
set $error $Name " Name can NOT contain imbedded spaces."
pos #1 " " $Name
if #1 > 0 return
set $error $Name " Name exceeds " #MaxName " char in length."
length #1 $Name
if #1 <= #MaxName set $error ""
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Subroutine to record script test results in next available file.
; after checking existing data files for folder name duplication
;
write_result:
set #1 1
name_loop:
set $filename $path
concat $filename "newdata" #1 ".fix"
if not fexist $filename goto write_OK
set $name " "
concat $name $DelName " " $NewName " " $ChgName " "
fopen &4 $filename
if ferror &4 goto file_error
freadln &4 $1
posnc #2 $1 $name
if #2 != 0 goto fnd_dupl
freadln &4 $1
posnc #2 $1 $name
if #2 != 0 goto fnd_dupl
freadln &4 $1
posnc #2 $1 $name
if #2 != 0 goto fnd_dupl
fclose &4
if ferror &4 goto file_error
inc #1
if #1 <= #MaxFldrs goto name_loop
goto end_wrtrst
fnd_dupl:
fclose &4
set $5 "N"
prompt $5 "Data exists for folder: " $1 " OVERWRITE? (Y/N)"
upcase $5
if $5 != "Y" goto alldone
; Page 8 of 13 ENS_MGRA.SCR
write_OK:
set $error " File Open "
fcreate &1 $filename
if ferror &1 goto file_error
set $error " File Write "
fwrite &1 $DelName %cr
fwrite &1 $ChgName %cr
fwrite &1 $NewName %cr
fwrite &1 $expire %cr
fwrite &1 $retain %cr
fwrite &1 $DelWire %cr
fwrite &1 $AddWire %cr
fwrite &1 $DelKey %cr
fwrite &1 #LoChgdKey %cr
fwrite &1 #HiChgdKey %cr
fwrite &1 $key1 %cr
fwrite &1 $key2 %cr
fwrite &1 $key3 %cr
fwrite &1 $key4 %cr
fwrite &1 $key5 %cr
fwrite &1 $key6 %cr
fwrite &1 $key7 %cr
if ferror &1 goto file_error
set $error " File Close "
fclose &1
if ferror &1 goto file_error
set $error ""
writeln "Data stored in file: " $filename
cwrite "Data stored in file: " $filename
return
end_wrtrst:
writeln "No more than " #MaxFldrs " files available."
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Subroutine writes existing personal folder characteristics to screen
;
get_old:
set $filename $path
concat $filename $ChgName ".KEY"
if not fexist $filename goto end_getold
fopen &1 $filename
if ferror &1 goto file_error
set #2 0
get_loop:
freadln &1 $1
inc #2
if #2 > 5 writeln $1
if not feof &1 goto get_loop
fclose &1
if ferror &1 goto file_error
end_getold:
return
; ENS_MGRA.SCR Page 9 of 13
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Subroutine to check for valid expiration date
; Parameters: $expire - the expiration date
; Returns: $error - error message (null if no error)
;
valid_days:
cls
set $9 %date
midstr $9 1 2
val #current_day $9
set $9 %date
midstr $9 4 3
set $moName $9
gosub moToNbr
set #current_month #moNbr
set $9 %date
midstr $9 8 2
val #current_year $9
; extract year, month, day from $expire
set $9 $expire
midstr $9 7 2
val #9 $9
set #expire_year #9
set $9 $expire
midstr $9 1 2
val #9 $9
set #expire_month #9
set $9 $expire
midstr $9 4 2
val #9 $9
set #expire_day #9
; get #maxDays, #moName for #expire_month - check they're legal
set #moNbr #expire_month
gosub daysInMonth
gosub moToName
set $1 "Month of " $moName " has only " #maxDays " days."
if #9 > #maxDays goto end_valid_days
; check it's not a past date
set $1 "Expiration can't be a PAST date; it must be in the future."
if #expire_year > #current_year goto end_past
if #expire_year < #current_year goto end_valid_days
; in the current year check months
if #expire_month > #current_month goto end_past
if #expire_month < #current_month goto end_valid_days
; in the current month check the days
if #expire_day < #current_day goto end_valid_days
end_past:
; Page 10 of 13 ENS_MGRA.SCR
; check that expiration date is within the next year
set $1 "Expiration date can't be MORE than one year into future."
if #expire_year = #current_year goto end_future
inc #current_year
if #expire_year > #current_year goto end_valid_days
; expires sometime next year so check the month
if #expire_month < #current_month goto end_future
if #expire_month > #current_month goto end_valid_days
; finally in current month check days
if #expire_day > #current_day goto end_valid_days
end_future:
set $1 ""
end_valid_days:
set $error $1
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Subroutine to convert month alpha to month number
; Parameter: $moName - month three letter alpha
; Returns: #moNbr - month number
;
moToNbr:
upcase $moName
if $moName = JAN set #moNbr 1
if $moName = FEB set #moNbr 2
if $moName = MAR set #moNbr 3
if $moName = APR set #moNbr 4
if $moName = MAY set #moNbr 5
if $moName = JUN set #moNbr 6
if $moName = JUL set #moNbr 7
if $moName = AUG set #moNbr 8
if $moName = SEP set #moNbr 9
if $moName = OCT set #moNbr 10
if $moName = NOV set #moNbr 11
if $moName = DEC set #moNbr 12
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Subroutine to convert month number to three letter alpha
; Parameter: #moNbr - month number to be converted
; Returns: $moName - month three letter alpha
;
moToName:
if #moNbr = 1 set $moName "JAN"
if #moNbr = 2 set $moName "FEB"
if #moNbr = 3 set $moName "MAR"
if #moNbr = 4 set $moName "APR"
if #moNbr = 5 set $moName "MAY"
if #moNbr = 6 set $moName "JUN"
if #moNbr = 7 set $moName "JUL"
if #moNbr = 8 set $moName "AUG"
if #moNbr = 9 set $moName "SEP"
if #moNbr = 10 set $moName "OCT"
if #moNbr = 11 set $moName "NOV"
if #moNbr = 12 set $moName "DEC"
return
; ENS_MGRA.SCR Page 11 of 13
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Subroutine to check for maximum number of days in a month
; Parameters: #moNbr - month number to be checked
; Returns: #maxDays - the last day in this month
;
daysInMonth:
set #maxDays 31
if #moNbr = 2 set #maxDays 28
if #moNbr = 9 set #maxDays 30
if #moNbr = 4 set #maxDays 30
if #moNbr = 6 set #maxDays 30
if #moNbr = 11 set #maxDays 30
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Subroutine to call check routine for each key phrase string
; Parameters: $key? - the set of seven key phrases
; Returns: $error - error message (null if no error)
;
valid_paren:
set $key $key1
gosub ck_paren
set $key $key2
gosub ck_paren
set $key $key3
gosub ck_paren
set $key $key4
gosub ck_paren
set $key $key5
gosub ck_paren
set $key $key6
gosub ck_paren
set $key $key7
gosub ck_paren
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Page 12 of 13 ENS_MGRA.SCR
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Subroutine to check for valid parenthesis matching
; Parameters: $key - key phrase to test
; Returns: $error - error message (null if no error)
;
ck_paren:
if $key = "" return
if $error != "" return
set $9 $key
length #3 $9
set #parentotl 0
lft_loop:
pos #1 "(" $9
pos #2 ")" $9
if #1 = 0 set #1 #3
if #2 = 0 set #2 #3
if #2 < #1 gosub rht_loop
if #2 = #1 goto end_paren
if #parentotl < 0 goto end_paren
inc #parentotl
inc #1
length #3 $9
midstr $9 #1 #3 $9
if #1 != 1 goto lft_loop
goto end_paren
rht_loop:
pos #1 "(" $9
pos #2 ")" $9
if #2 = 0 set #2 #3
if #1 = 0 set #1 #3
if #1 <= #2 return
dec #parentotl
if #parentotl < 0 return
inc #2
length #3 $9
midstr $9 #2 #3 $9
if #2 != 1 goto rht_loop
end_paren:
if #parentotl != 0 set $error "Unmatched parenthesis: " $key
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Subroutine to record validation tests for debug use
;
offline_test:
set $1 "TESTDATA"
set $filename $path
concat $filename $1 ".MGR"
capture ON $filename
cwrite "ens_mgr.scr TEST " %date " at " %time " OFFLINE" %cr
gosub record_data
capture OFF ;$filename
return
; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;END OF FILE
; ENS_MGRA.SCR Page 13 of 13