%!ps
% fixwhtnumenus1 attempts to repair whtnu menues
% =======
% Author and date
% Function
% Details
% ======
% version 08 does not have tables! modified below
% Postscript demo to generate css compatible $20 URL space
% Intended primarily for study as this was an internal workfile.
% Requires gonzo, gonzotut, and several older files relocated.
% Requires //acrodist /F from command line.
% Cut and paste .txt generated code from chrome, not wordpad.
% =======
% Uncomment and modify to use disk based Gonzo. ( or other disk access )
(C:/Users/Don/Desktop/Ghost/gonzo.psl) run % use internal
/guru { gonzo begin
ps.util.1 begin printerror nuisance begin} def
guru % activate gonzo utilities
% ========== month names =======
/monthnames [ % needed to get from xx.xx.xx to live date
(January)
(February)
(March)
(April)
(May)
(June)
(July)
(August)
(September)
(October)
(November)
(December)
] store
% ======= set files ====
/setfiles {
/fileprefix (C:/Users/don/Desktop/web/whtnu_rework/whtnu08_rework/) store
/infilename (whtnu08oldmode.shtml) store % has new front and back
/outfilename (whtnu08newe.shtml) store
% change date below!!!
/startarray [ ] store
/endarray [ ] store
/ststr () store
fileprefix infilename mergestr (r) file /nf exch store
fileprefix outfilename mergestr (w) file /nfd exch store
} store
% ======= make arrays ====
% findstart stashes the start and end filepositions for
% each header to be substituted
/findstart {/endfile false store
2000000 {/endfile false store
nf 3 string readstring {
(="x)
% 2 copy == ==
% startarray ==
eq{ nf fileposition 5 sub 19 sub
/cur exch store % adjust start
mark startarray aload pop cur ]
/startarray exch store
findend endfile {exit} if
} if
} {pop /endfile true store exit} ifelse % got to end
endfile {exit} if % forced by nest
nf fileposition 2 sub nf exch setfileposition
} repeat
} store
% findend finds the original menu locations
/findend { 20000 { nf 8 string readstring {
(respond<) eq
{ nf fileposition 11 add
/cur exch store % adjust pos
mark endarray aload pop cur ]
/endarray exch store exit } if
} { pop /endfile true store exit} ifelse % got to end
nf fileposition 7 sub nf exch setfileposition
} repeat} store
% reportarrays is for debug...
/reportarrays { {(\n\nthese are the arrays...\n\n) print
startarray dup length == ==
endarray dup length == ==
startarray length endarray length eq
{(\n\nArray lengths agree at ) endarray
length 20 string cvs mergestr (!!\n\n)
mergestr print}
{(\n\nArray lengths mismatch! CHECK ORIGINAL!!\n\n)
print} ifelse} if } store
% make beginning creates the string up to the first menu
/makebeginning {
fileprefix infilename mergestr (r) file /nf exch store
fileprefix outfilename mergestr (w) file /nfd exch store
startarray 0 get 7 sub string nf exch readstring
{ }{beginning_too_long} ifelse /begstring exch store } store
/reportbeginning { { (\n\nbegstring is now\n) print begstring print
(\n\n) print} if } store
/writebeginning {nfd begstring writestring} store
%%%%%%%%%%%%%%%%%%%%%%%
/getoldmenu {
nf fileposition 7 add nf exch setfileposition % get rid of leading
endarray curloop get
startarray curloop get sub 8 sub % trailing
) mergestr fulldate mergestr ( | \ndeeplink top bot respond |
<
nfd newmenu writestring } store
/adjmenucontents { % attempts to flush anything before
menucontents (
) search
{
pop exch mergestr
/menucontents exch store
}{ (\n\nnoblockquote!\n) print } ifelse
} store
/getmenucontents {
startarray curloop 1 add get
endarray curloop get sub 1 add string % zzz short
nf exch readstring {}{}ifelse
/menucontents exch store
adjmenucontents
} store
/reportmenucontents {
(\n\nmenu contents is ) menucontents mergestr (\n\n) mergestr print
} store
/writemenucontents { nfd menucontents writestring} store
/loopmenus { /reportloops false store
0 1 startarray length 2 sub {/curloop exch store
getoldmenu
% true {reportoldmenu} if % show old menu?
extractnewvalues
% true {reportnewvalues} if % show extracted values
buildnewmenu
true {reportnewmenu} if % show new menu
writenewmenu
getmenucontents
true {reportmenucontents}if
writemenucontents
} for
} store
/writeend { nf 60000 string readstring
{}{} ifelse
nfd exch writestring
} store
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% actual code starts here...
stopwatchon
setfiles
findstart % build array
% true reportarrays % optionally report
makebeginning % create up to first menu
% true reportbeginning % optionally report
writebeginning % and write to file
loopmenus % create menu-data pairs
writeend % and beyond menu-data pairs
stopwatchoff
% glotzify
nfd closefile
(\n\n) print
(\n\n) print
%EOF