<<<<<<<<<<<<<<<<<<<< STARTBUNDLEDATA <<<<<<<<<<<<<<<<<<<<
<<<<<<<<<<<<<<<<<<<< XCHK_AFM.AWK <<<<<<<<<<<<<<<<<<<<
# XCHK_AFM.afm (DOS/GAWK version)
#    usage: gawk -f xchk_afm.awk
#
# Check group of AFM files for different layout and each afm/pfb pair 
# for consistency (the same layout). AFM/PFB files should be present
# in the current directory.
#
# Note: T1DISASM shoud be present in your system while running this script!
#
# TP (april 5, 1996)
#

# CMP_FILES: compare afm/pfb layout
function cmp_files() {
   for (i=1; i<=pfb_char_num; i++)
        if ( pfb_char[i] != char[i] ) {return (1);  }
   return (0)
}

# CHK_PFB: extract characters from pfb file
function chk_pfb(fn, xc) {
   gsub (/\.AFM/,"\.PFB", fn); # we are checking pfb file now;
   print fn, "found" >> stdio;
   ## system ("arj x.....") ##
   
   system ("t1disasm " fn "\> disasm.tmp") #
   scan = 0;
   xc = 0;

   while ( (getline pfb < "disasm.tmp" )  > 0) {
      
      if (pfb ~ /\/CharStrings/) {
         scan = 1; 
         print "Scanning pfb..." >> stdio;
         getline pfb < "disasm.tmp";
      } 
      else {
         if ( (scan == 1) && (pfb ~ /readonly put put/) ) {
            scan = 0; 
            print "\ndone..." >> stdio;; 
            close ("disasm.tmp");
            return (xc);
         }
      }

      if (scan && pfb ~ /^\//) {##
          xc++;
          gsub(/\//,"", pfb);
          split(pfb, tmp, " ");
          pfb_char[xc] = tmp[1];
          printf "" >> stdio;
      }
   }

   # in case of any strange error we put:
   close ("disasm.tmp")
   return(-1);
}

# MAIN routine:
BEGIN { stdio = "con" # stdio for DOS


   while (("dir/b *.afm" | getline  fname ) > 0) {
      scan = 0;    charno = 0;
      print "\n" fname, "found" >> stdio;
      files++;

      pfb_char_num = chk_pfb(fname);

      print "Chars defined in pfb file:", pfb_char_num >> stdio;
      

      while ( (getline < fname )  > 0) {

         if ($1 == "StartCharMetrics") {scan = 1; getline < fname } else 
            {if ($1 ~ "EndCharMetrics") {scan = 0; break }}

         if (scan) {# ###
            charno++;
            char[charno] = $8;
         }
      }
     
      print "Chars defined in afm file:", charno >> stdio;
      if ( cmp_files() ) { print " Afm/pfb files are inconsistent!" >> stdio; }

      # chk all layouts --------------------
      maxcharno = charno 

      if (files==1) {# scanning first file --
         layout_num = 1;
         layouts[0,layout_num] = fname;  # store file name 
         for (i=1; i <= charno; i++) { layouts[i,layout_num] = char[i] }
      } 
      else {

         for (i=1; i<=layout_num; i++) {
             diff = 0; 
             for (j=1; j <= charno; j++) {
                 if (layouts[j,i] != char[j]) { diff++ }
                    # ##print layouts[j,i], char[j];
             }

             
             if (diff == 0) {# found identical
                layouts[0,i] = layouts[0,i] ";" fname; # store file name 
                break; 
             }
         }


         if (diff) {## another layout!
            print "New layout found!" >> stdio;
            layout_num++;
            for (i=1; i <= charno; i++) { 
               layouts[i,layout_num] = char[i] 
            }

            layouts[0,layout_num] = fname; # store file name 
         }   

      }

     close (fname)

   }
   close ("dir/b *.afm");
 
   # Print characters in all layouts

   printf "Scanned %d files\n", files >> stdio;
   printf "Found %s layout(s)\n", layout_num >> stdio;
   printf "inspect chk-afm.log file for details\n", layout_num >> stdio;

   # once again to log file (possible)

   printf "Scanned %d files\n", files;
   printf "Found %s layout(s)\n", layout_num;
   printf " detailed statistics is as follows:\n";

   for (i=1; i<=layout_num; i++) {print " -- layout", i, "in: ", 
        layouts[0,i];}

   for (i=1; i<=layout_num; i++) {
      printf "\nLayout %d\n======\n", i;
      clen = 0;

      for (j=1; j<=maxcharno; j++) {
           printf "%s, ", layouts[j,i];
           clen += (2 + length(layouts[j,i]));
           if (clen > 60) { clen = 0; printf "\n"; }
      }
      printf "\n";
   }
   
}

>>>>>>>>>>>>>>>>>>>> XCHK_AFM.AWK >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< 2BL.INF <<<<<<<<<<<<<<<<<<<<
Cze/s/c

Podsy/lam przyk/lady AWK-owe przygotowane przeze mnie z my/sl/a (tak/ze)
o Bachotku. Sp/ojrz w szczeg/olno/sci na XCHK_AFM.AWK (sprawdzacz 
plik/ow AFM//PFB -- mo/zesz spr/obowa/c sprawdzi/c bibliotek/e BS-500),
SPJ.AWK (prosta wersja programu dodaj/acego tyldy do sp/ojnik/ow)
oraz PS2PK (u/latwia generowanie font/ow za pomoc/a PS2PK). 

Inne pliki to takie TOY-EXAMPLES ale s/a w nich interesuj/ace idee, 
by/c mo/ze te/z je warto pokaza/c. Oto pe/lna lista (ciekaw jestem 
twoich opinii).

  XCHK_AFM.AWK -- sprawdzacz plik/ow AFM//PFB
  SPJ.AWK -- dodawacz tyld do sp/ojnik/ow
  PS2PK.AWK -- generator font/ow PK (automatyzuje program ps2pk)

  CHKBIG.AWK   -- wyszukuje 1MB i wi/eksze pliki na dysku
  CLICHE.AWK   -- generator hase/l (przyk/lad na rozbawienie publiki)
  WFREQX.AWK   -- podaje list/e s/l/ow tekstu i ich liczebno/s/c
  CHK_REP.AWK  -- modyfikacja WFREQX.AWK
  BUNDLE.AWK   -- wszystkie pliki z katalogu kopiuje do pliku bundle.txt
  UNBUNDLE.AWK -- z pliku bundle.txt wydobywa pliki sk/ladowe
  DOW.AWK      -- po/zyteczna funkcja data -> dzie/n tygodnia
  CHKDAT       -- wyszukuje na dysku pliki z dzisiejsz/a dat/a
  QSORT        -- implemetacja algorytmu qsort (z AWKbook)


Druga sprawa to opis samego AWK. Do om/owienia jest:

1. Wst/ep; to ju/z jest, to co napisa/le/s jest dobre, ewentualnie
   doda si/e jakie/s 1--2 przyk/ladziki.

2. Wzorce, trzeba opisa/c dok/ladniej (BEGIN, END, wyra/zenie,
   wyra/zenie-reg., wyra/zenie z przecinkiem).
   Mam troszeczk/e na ten temat

3. Wyra/zenia regularne.

4. Wyra/zenia arytmetyczne plus operator konkatenacji napis/ow.

5. Arytmetyczne funkcje wbudowane.

6. Napisowe funkcje wbudowane.

7. Instrukcje steruj/ace.

8. Tablice asocjacyjne i operacje na nich.

9. Instrukcje wyj/scia -- print//printf.

10. Czytanie danych -- instrukcja getline.
    (napisa/lem na ten temat troch/e)

11. Parametry wywo/lania programu.

12. Funkcje definiowane przez u/zytkownika.

Proponuj/e nast/epujacy podzia/l pracy:

BL -> 1, 2, 3,  4,  5, 7
TP -> 6, 8, 9, 10, 11, 12

Je/zeli nie masz uwag to bie/z sie do pracy. Forma na razie nie ustalona
pracuj nad tre/sci/a. Pod koniec tygodnia zbie/zemy do kupy teksty
ustalimy dok/ladny layout w oparciu o moje i twoje pomysly. OK?


--Tomek
            
>>>>>>>>>>>>>>>>>>>> 2BL.INF >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< CHK_REP.AWK <<<<<<<<<<<<<<<<<<<<
# Report frequency of all lines in the document
# Author: B. Jackowski (MSDOS/GAWK version)
#
{if ($0 in E) {E[$0]+=1} else {E[$0]=1}}

END {for (i in E) {if (E[i] > 1) {print i, E[i]}}}
>>>>>>>>>>>>>>>>>>>> CHK_REP.AWK >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< CHKBIG.AWK <<<<<<<<<<<<<<<<<<<<
# CHKBIG.awk
# Wy/swietla pliki kt/orych wielko/c/s jest wi/eksza od SIZE
# znajduj/ace si/e na bie/z/acym dysku
# 
# Autor: TP (22.3.1996)
#
BEGIN {
   flag = 1
   SIZE = 1000000 #
   while ("dir \\/s" | getline) {
      gsub("\\.","");
      
      if ($0 !~ /^ / && $0 !~ "\<DIR\>" && NF>3 && $(NF-2) > SIZE) {print $0; flag =0}

   }

   if (flag) {print "NO FILES BIGGER THAN", SIZE, "FOUND!"; }
}

>>>>>>>>>>>>>>>>>>>> CHKBIG.AWK >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< CLICHE.AWK <<<<<<<<<<<<<<<<<<<<
# CLICHE.awk -- Generator hase/l (wersja: DOS/GAWK)
#   Spos/ob u/zycia:   gawk -f cliche.awk cliche.txt
# 
# Autor: TP (22.3.1996)
#

function randint(n) { return int(n * rand() ) + 1; }

BEGIN { 
MAX =200; # number of generated sentences
stdio = "con" # for DOS
RS = ""; FS = "\n"; 
srand(); 
clen = 1; cpar = 1;
printf "CLICHE GENERATOR v. 0.33(alpha)\n" > stdio;
printf "Generating %d sentences\n", MAX > stdio;
printf "Each _o_ means paragraph\n" > stdio;

}

{ x1[NR] = $1; x2[NR] = $2; x3[NR] = $3; x4[NR] = $4; }

END { 
    for (i=1; i < MAX; i++) {
        l = sprintf ("%s %s %s %s", x1[randint(NR)], x2[randint(NR)], 
            x3[randint(NR)], x4[randint(NR)] );

        chars += length(l);

        gsub("\n", " ", l);

        llen = split (l, a, " ");

        for (j = 1; j<= llen; j++) {
            printf"%s ", a[j];
            if (clen % 7 == 0) {print; chars+=2; clen = 0; }
            clen++
        }

        if (randint(500) == 1 && (cpar > 5)) {
            printf "\n\n"; chars+=2; cpar = 0;

            printf "o" > stdio;
            totpar++; # count paragraphs

        }
        cpar++;

    }
 
    printf "\n%d paragraphs generated successfully!", totpar > stdio;
    printf "\n%d charactes", chars > stdio;
}
>>>>>>>>>>>>>>>>>>>> CLICHE.AWK >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< BUNDLE.BAT <<<<<<<<<<<<<<<<<<<<
gawk -f bundle.awk
>>>>>>>>>>>>>>>>>>>> BUNDLE.BAT >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< SPJ.AWK <<<<<<<<<<<<<<<<<<<<
# Spojnik.awk (MS-DOS version)
#    usage:  gawk -f spj.awk plik, plik...
# 
# Dodaje nie/lamliwe spacje po sp/ojnikach, przed inicja/lami 
# oraz do niekt/orych skr/ot/ow. Zamienia /laczniki w odpowiednich 
# miejscach na p/o/lpauzy.
#
# Author: TP (5.4.96)
#

BEGIN {
   stdio = "con";
   digit = "[0123456789]"; 
   capletter = "[A-Z]";  # Mazovia format
   lowletter = "[a-z]";  # Mazovia format
   spojnik = "[AIOUWZaiouwz]"; 
   wspace = "[ \\t\\n]+";
}

# wymie _co_ w kontekcie _bef_ _aft_ na _na_
# designed by: Marek Ryko

function exch (bef, co, aft, na) {
   while (match(para, bef co aft) > 0) {
       match(para, bef co aft);
       nowy = substr(para, 1, RSTART) na substr(para, RSTART+RLENGTH-1);
       para = nowy;
   }
}

# wymie _co_ w kontekcie _bef_ _aft_ na _na_
# original idea: Marek Ryko

function xexch (bef, co, aft, na) {
   while (match(para, bef co aft) > 0) {
       match(para, bef co aft); R1 = RSTART; L1 = RLENGTH;

       test = substr(para,RSTART,RLENGTH);

       test1 = match(test,bef); R2 = RSTART; L2 = RLENGTH;
       test2 = match(test,aft); R3 = RSTART; L3 = RLENGTH;

       nowy = substr(para, 1, R1 + L2 - 1) na substr(para, R1 + L1 - L3);
       para = nowy;
   }
}


function print_para() {
   len = 0;
   words = split(para, paralist," ");
   for (i=1; i<=words; i++) {
      len += length(paralist[i]);
      ##print len, paralist[i] >> stdio;

      if ( ++len >= 60 ) { printf "%s\n", paralist[i]; len = 0 }
      else { printf "%s ", paralist[i]; }
   }
   if (len) { printf "\n\n"; } else { printf "\n";}
}

function process_para() {
   print "Paragraph: ", length(para), "bytes" >> stdio;

   gsub(/[ \t\n]+a[ \t\n]+/, " a~", para); gsub(/\~a /, "~a~", para);
   gsub(/[ \t\n]+i[ \t\n]+/, " i~", para); gsub(/\~i /, "~i~", para);
   gsub(/[ \t\n]+o[ \t\n]+/, " o~", para); gsub(/\~o /, "~o~", para);
   gsub(/[ \t\n]+u[ \t\n]+/, " u~", para); gsub(/\~u /, "~u~", para);
   gsub(/[ \t\n]+w[ \t\n]+/, " w~", para); gsub(/\~w /, "~w~", para);
   gsub(/[ \t\n]+z[ \t\n]+/, " z~", para); gsub(/\~z /, "~z~", para);

   gsub(/[ \t\n]+A[ \t\n]+/, " A~", para); gsub(/\~A /, "~A~", para);
   gsub(/[ \t\n]+I[ \t\n]+/, " I~", para); gsub(/\~I /, "~I~", para);
   gsub(/[ \t\n]+O[ \t\n]+/, " O~", para); gsub(/\~O /, "~O~", para);
   gsub(/[ \t\n]+U[ \t\n]+/, " U~", para); gsub(/\~U /, "~U~", para);
   gsub(/[ \t\n]+W[ \t\n]+/, " W~", para); gsub(/\~W /, "~W~", para);
   gsub(/[ \t\n]+Z[ \t\n]+/, " Z~", para); gsub(/\~Z /, "~Z~", para);
   
   gsub(/[ \t\n]+r\./, "~r.",para); # year

   #intials#
   xexch(capletter, "\\.[ \t\n]+", capletter lowletter, "\.\~");
   xexch(capletter, "\\.[ \t\n]+", capletter "\\.\\~", "\.\~");

   #endashes#
   exch(digit,"-",digit, "--");
   xexch(digit, wspace "-" wspace, digit, "--");

   #now we can convert emdashes#
   gsub(wspace "-" wspace, " -- ", para);

   print_para();
   para = "";
}

{ para = para " " $0; if (match($0,/^[\t ]*$/) ){process_para()} }
END {process_para(); }


>>>>>>>>>>>>>>>>>>>> SPJ.AWK >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< UNBUNDLE.AWK <<<<<<<<<<<<<<<<<<<<
# Unbundle.awk (MS-DOS version)
#    usage:  gawk -f unbundle.awk
# 
# unbundles files bundled by _bundle.awk_ script to file which
# name is defined by _bundlefile_ variable (see below)
#
# Author: TP (5.4.96)
#
BEGIN { stdio = "con" # stdio for DOS
        seplineb = "<<<<<<<<<<<<<<<<<<<<";
        seplinee = ">>>>>>>>>>>>>>>>>>>>";
        bundlefile = "BUNDLE.TXT";
        dircontents = ":";

   
   # get the contents of the current directory--

   while (("dir/b *.*" | getline) > 0) { dircontents = dircontents $0 ":"; }
   
   while ( (getline < bundlefile )  > 0) {
      if ( $2 == "STARTBUNDLEDATA") { break; }
   }

   while ( (getline < bundlefile )  > 0) {
        if ( $1 == seplinee && $3 == seplinee && $2 == "ENDBUNDLEDATA") { break; }
        
        if ( $1 == seplineb) { 
           fname = $2;  xfname = ":" $2 ":"; 
           print "Unbundling", fname >> stdio;
           if (match (dircontents, xfname) > 0 && fname !="UNBUNDLE.AWK") {
               print "\nFile", fname, "already exist, quitting...";
               print "Try unpack", bundlefile, "in an empty dir!";
               exit;
           }
        } 
        else { 
           if ( $1 == seplinee) { close (fname)} 
           else {
              print $0 > fname;
           }
        }
  }
}
           
>>>>>>>>>>>>>>>>>>>> UNBUNDLE.AWK >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< WFREQX.AWK <<<<<<<<<<<<<<<<<<<<
# WFREQX.awk
#   usage: gawk -f wfreqx.awk file (raven.txt is delivered for testing)
#
# Print list of word frequencies
# idea borrowed from: GAWK manual p.~141
# coding and extension TP (24.3.96)
#
{ gsub(/[\.,;:"'`!?]/,""); gsub("---"," "); }
{ for (i=1; i <= NF; i++) { freq[$i]++ } }
END {for (word in freq) { printf "\%s\t%d\n", word, freq[word] }}
>>>>>>>>>>>>>>>>>>>> WFREQX.AWK >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< CLICHE.TXT <<<<<<<<<<<<<<<<<<<<
Szanowni Pastwo
nowy model dziaalnoci wyrosy z ducha reform
pomaga w przygotowaniu i realizacji
programu szeroko rozumianej, zgodnej z wymogami wspczesnoci edukacji spoeczestwa.

Drodzy towarzysze
szeroka realizacja przyjtych na naszym poprzednim zebraniu uchwa
spenia donios rol w ksztatowaniu i umacnianiu
zasady sprawiedliwoci spoecznej.

W ten sposb 
rozpoczcie powszechnej dyskusji nad dalszym ksztatem dziaalnoci
stwarza nowe moliwoci dziaania na rzecz
postaw kadego Polaka -- a powiem wicej: rwnie kadej Polki -- wobec wyzwa przyszoci jakie przed nami stoj.

Nie bd ukrywa, e
stae zabezpieczenie informacyjne 
powoduje docenienie roli i wagi
podanego modelu samorzdnoci.

Troska wadzy ustawodawczej i wykonawczej o
dalsze doskonalenie nakrelonych w programie dziaa
zmusza nas do dokonania miaych korekt
drogi najwszechstronniej rozumianego postpu, z ktrej nie damy si zepchn.

W tym gronie moemy sobie jasno i szczerze powiedzie, e
braterskie zacienianie stosunkw z bratnimi organizacjami
jest dobrze przyjtym przykadem nowoczesnego, europejskiego rozumienia
struktur politycznych i ekonomicznych, wypracowanych z naszej inicjatywy i przy naszym udziale przy wsplnym okrgym stole.

Roli i znaczenia dzisiejszej dyskusji nie trzeba szerzej uzasadnia, std
konsekwentny, dynamiczny wzrost iloci imprez i akcji
w jeszcze wikszym ni dotychczas stopniu umoliwia tworzenie
nowego ksztatu niepodlegej i zasobnej Polski na miar standardw XXI wieku.

Powysze zaoenia programowe a take
zakres i miejsce szkolenia naszych modych zwolennikw
sprzyja bdzie rozszerzaniu
modelu rozwoju dynamicznych zmian rynkowych przy penym poszanowaniu praw warstw najsabszych i trosce o ich renty i emerytury.

Std te w tym pakiecie
konsultacja z szerokim aktywem i aparatem
pociga za sob proces wdraania i unowoczeniania
ambitnych dziaa spoecznych i gospodarczych, dziki ktrym nasza formacja przejdzie do Historii.

Tak wic w wietle tego, co przed chwil zostao powiedziane,
umacnianie starych i zakadanie nowych ogniw naszej organizacji
zabezpiecza udzia licznych rzesz czonkowskich w budowaniu
historycznych przeobrae 1989 roku i pniejszych dokona koalicji SLD-PSL.
>>>>>>>>>>>>>>>>>>>> CLICHE.TXT >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< RAVEN.TXT <<<<<<<<<<<<<<<<<<<<
Edgar Alan Poe ``The Raven''

Once upon a midnight dreary, while I pondered, weak and weary,
Over many a quaint and curious volume of forgotten lore---
While I nodded, nearly napping, suddenly there came a tapping,
As of some one gently rapping, rapping at my chamber door.
``' Tis some visiter,'' I muttered, ``tapping at my chamber door---
Only this and nothing more.''

Ah, distinctly I remember it was in the bleak December;
And each separate dying ember wrought its ghost upon the floor.
Eagerly I wished the morrow;---vainly I had sought to borrow
From my books surcease of sorrow---sorrow for the lost Lenore---
For the rare and radiant maiden whom the angels name Lenore---
Nameless here for evermore.

And the silken, sad, uncertain rustling of each purple curtain
Thrilled me---filled me with fantastic terrors never felt before;
So that now, to still the beating of my heart, I stood repeating
``'Tis some visiter entreating entrance at my chamber door---
Some late visiter entreating entrance at my chamber door;---
This it is and nothing more.''

Presently my soul grew stronger; hesitating then no longer,
``Sir,'' said I, ``or Madam, truly your forgiveness I implore;
But the fact is I was napping, and so gently you came rapping,
And so faintly you came tapping, tapping at my chamber door,
That I scarce was sure I heard you''---here I opened wide the door;---
Darkness there and nothing more.

Deep into the darkness peering, long I stood there wondering, fearing,
Doubting, dreaming dreams no mortal ever dared to dream before;
But the silence was unbroken, and stillness gave no token,
And the only word there spoken was the whispered word, ``Lenore?''
This I whispered, and an echo murmured back the  word, ``Lenore!''
Merely this and nothing more.

Back into the chamber turning, all my soul within me burning,
Soon again I heard a tapping somewhat louder than before.
``Surely,'' said I, ``surely that is something at my window lattice;
Let me see, then, what thereat is, and this mystery explore---
Let my heart be still a moment and this mystery explore;---
'Tis the wind and nothing more!''

Open here I flung the shutter, when, with many a flirt and flutter,
In there stepped a stately Raven of the saintly days of yore;
Not the least obeisance made he; not a minute stopped or stayed he;
But, with mien of lord or lady, perched above my chamber door---
Perched upon a bust of Pallas just above my chamber door---
Perched, and sat, and nothing more.

Then this ebony bird beguiling my sad fancy into smiling,
By the grave and stern decorum of the countenance it wore,
``Though thy crest be shorn and shaven, thou,'' I said, ``art sure no craven,
Ghastly grim and ancient Raven wandering from the Nightly shore---
Tell me what thy lordly name is on the Night's Plutonian shore!''
Quoth the Raven ``Nevermore.''

Much I marvelled this ungainly fowl to hear discourse so plainly,
Though its answer little meaning---little relevancy bore;
For we cannot help agreeing that no living human being
Ever yet was blessed with seeing bird above his chamber door---
Bird or beast upon the sculptured bust above his chamber door,
With such name as ``Nevermore.''

But the raven, sitting lonely on the placid bust, spoke only 
That one word, as if his soul in that one word he did outpour.
Nothing farther then he uttered---not a feather then he fluttered---
Till I scarcely more than muttered ``Other friends have flown before---
On the morrow he will leave me, as my Hopes have flown before.''
Then the bird said ``Nevermore.''

Startled at the stillness broken by reply so aptly spoken,
``Doubtless,'' said I, ``what it utters is its only stock and store
Caught from some unhappy master whom unmerciful Disaster
Followed fast and followed faster till his songs one burden bore---
Till the dirges of his Hope that melancholy burden bore,
Nevermore--- Ah nevermore.'''

But the Raven still beguiling my sad fancy into smiling,
Straight I wheeled a cushioned seat in front of bird, and bust and door;
Then, upon the velvet sinking, I betook myself to linking
Fancy unto fancy, thinking what this ominous bird of yore---
What this grim, ungainly, ghastly, gaunt, and ominous bird of yore
Meant in croaking ``Nevermore.''

This I sat engaged in guessing, but no syllable expressing
To the fowl whose fiery eyes now burned into my bosom's core;
This and more I sat divining, with my head at ease reclining
On the cushion's velvet lining that the lamp-light gloated o'er,
But whose velvet-violet lining with the lamp-light gloating o'er,
She shall press, ah, nevermore!

Then, methought, the air grew denser, perfumed from an unseen censer
Swung by seraphim whose foot-falls tinkled on the tufted floor.
"Wretch," I cried, "thy God hath lent thee---by these angels 
he hath sent thee
Respite---respite and nepenthe from thy memories of Lenore;
Quaff, oh quaff this kind nepenthe and forget this lost Lenore!"
Quoth the Raven "Nevermore."

"Prophet!" said I, "thing of evil!---prophet still, if bird or devil!---
Whether Tempter sent, or whether tempest tossed thee here ashore,
Desolate yet all undaunted, on this desert land enchanted---
On this home by Horror haunted---tell me truly, I implore---
Is there---is there balm in Gilead?---tell me---tell me, I implore!"
Quoth the Raven "Nevermore."

"Prophet!" said I, "thing of evil!---prophet still, if bird or devil!---
By that Heaven that bends above us---by that God we both adore---
Tell this soul with sorrow laden if, within the distant Aidenn,
It shall clasp a sainted maiden whom the angels name Lenore---
Clasp a rare and radiant maiden whem the angels name Lenore."
Quoth the Raven "Nevermore."

"Be that word our sign of parting, bird or fiend!" I shrieked, 
upstarting---
"Get thee back into the tempest and the Night's Plutonian shore!
Leave no black plume as a token of that lie thy soul hath spoken!
Leave my loneliness unbroken!---quit the bust above my door!
Take thy beak from out my heart, and take thy form from off my door!"
Quoth the Raven "Nevermore."

And the Raven, never flitting, still is sitting, still is sitting,
On the pallid bust of Pallas just above my chamber door;
And his eyes have all the seeming of a demon's that is dreaming,
And the lamp-light o'er him streaming throws his shadow on the floor;
And my soul from out that shadow that lies floating on the floor
Shall be lifted---nevermore!
>>>>>>>>>>>>>>>>>>>> RAVEN.TXT >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< CHK-AFM.BAT <<<<<<<<<<<<<<<<<<<<
:: MS-DOS script for executing xchk_afm.awk
:: TP (april, 96)
gawk -f xchk_afm.awk > chk-afm.log
>>>>>>>>>>>>>>>>>>>> CHK-AFM.BAT >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< AFM-EXT.BAT <<<<<<<<<<<<<<<<<<<<
:: Extracting specific AFM file from afm file directory
:: T.Przechlewski (1995)
@if %1.==. goto ERROR
@if exist \gslib\afmfiles\%1.afm goto END
@if exist %1.afm goto END
  arj x \gslib\afmfiles\afmfiles.arj %1.afm
  @if not exist %1.afm goto ERROR
  goto END
:ERROR
  @echo NO FILE EXTRACTED!
:END

>>>>>>>>>>>>>>>>>>>> AFM-EXT.BAT >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< BUNDLE.AWK <<<<<<<<<<<<<<<<<<<<
# Bundle.awk (MS-DOS version)
#    usage:  gawk -f bundle.awk
# 
# bundle files to file which name is defined by _bundlefile_ 
# variable (see below), these can be reprocessed by _undundle.awk_
#
# Author: TP (5.4.96)
#
BEGIN { stdio = "con" # stdio for DOS
        seplineb = "<<<<<<<<<<<<<<<<<<<<";
        seplinee = ">>>>>>>>>>>>>>>>>>>>";
        bundlefile = "BUNDLE.TXT";

   print seplineb, "STARTBUNDLEDATA", seplineb > "bundle.txt";
        
   while (("dir/b/a-d *.*" | getline  fname ) > 0) {
      print fname, "found..." >> stdio;
      if (fname == bundlefile) { print "\tfile", bundlefile, "skipped!"; continue; }
      print seplineb, fname, seplineb > "bundle.txt";

      while ( (getline < fname )  > 0) {
         print $0 > "bundle.txt";
      }
      print seplinee, fname, seplinee > "bundle.txt";
      close (fname)
   }

   print seplinee, "ENDBUNDLEDATA", seplinee > "bundle.txt";
   close ("dir/b *.*");
}
>>>>>>>>>>>>>>>>>>>> BUNDLE.AWK >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< PS2PK.BAT <<<<<<<<<<<<<<<<<<<<
:: ============================================================
:: This batch automate rendering *.pfb fonts using ps2pk
:: program and moves *.pk files to the appropriate directories
:: 
:: usage: PS2PK _font-name_ _resolution_ _encoding_
::       _font-name_  pfb font name without extension
::       _resolution_ resolution in dpi
::       _resolution_ filename containing encoding vector (optional)
::
:: It is assumed encoding files (*.enc) are in the directories specified
:: by the environment variable TEXCONFIG and PostScript fonts (*.pfb)
:: files are in the directory specified by the variable T1INPUTS
::
:: The *.pk files are searched in the directory .\lofo, if not
:: found they are rendered and stored there.
::
:: 				   T.Przechlewski (1995, march)
:: ============================================================
@echo off
 if exist lofo\nul goto CONTINUE
 echo Creating local directory...
 md lofo 
:CONTINUE
 if %2.==. goto DEFAULT
 if exist lofo\%2\%1.pk goto EXIST
 call afm-ext %1
 if %3.==. goto BUILTIN
 echo The encoding vector is: %3!
 c:\bin\ps2pk.exe -v -e%3 -X%2 -Y%2 %1.pfb %1.%2
 goto CONT
:BUILTIN 
 echo The encoding vector is not changed!
 c:\bin\ps2pk.exe -v -X%2 -Y%2 %1.pfb %1.%2
:CONT
 if not exist %1.%2 goto ERROR
 if not exist lofo\%2\nul md lofo\%2
 move %1.%2 lofo\%2\%1.pk
 goto END
:DEFAULT
 if exist lofo\300\%1.pk goto EXIST
 echo The encoding vector is not changed!
 c:\bin\ps2pk.exe -v %1.pfb %1.pk
 goto END
:ERROR
 echo STRANGE ERROR: probably there is no pfb/afm file on your system!
 goto END
:EXIST
 echo File already EXIST!
:END
>>>>>>>>>>>>>>>>>>>> PS2PK.BAT >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< QSORT.AWK <<<<<<<<<<<<<<<<<<<<
# quicksort (AWK book -- p.~161)
#

{ for (i=1; i<=NF; i++){ A[++eleno] = $i;} }
END { qsort(A, 1, eleno); for (i=1; i<= eleno; i++){ print A[i] }}

# qsort -- sort A[left..right] by quicksort

function qsort(A, left, right,     i, last) {
   if (left >= right) # do nothing if array contains
      return          # less than two elements
   swap(A, left, left + int((right-left+1)*rand()))
   last = left # A[left] is now partition element
   for (i=left+1; i<=right; i++) {
        if (A[i] < A[left]) { swap(A, ++last, i) }
   }
   swap(A, left, last);
   qsort(A, left, last-1);
   qsort(A, last+1, right);
}

function swap(A,i,j, tmp) { tmp = A[i]; A[i] = A[j]; A[j] = tmp; }
>>>>>>>>>>>>>>>>>>>> QSORT.AWK >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< CLICHE.BAT <<<<<<<<<<<<<<<<<<<<
gawk -f cliche.awk cliche.txt > cliche.out
>>>>>>>>>>>>>>>>>>>> CLICHE.BAT >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< QTEST.TXT <<<<<<<<<<<<<<<<<<<<
Konstanty
Ala
Wacaw
Bela
aps
Ignacy

>>>>>>>>>>>>>>>>>>>> QTEST.TXT >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< EG.CNF <<<<<<<<<<<<<<<<<<<<
% eg.cnf (300x300 DPI using LJ fonts)
%/pd={,$DVIDRVINPUT:}@i
%% fonty PK
/pf={.\lofo\@Rr\,..\lofo\@Rr\,c:\tex\pxl\@Rr\,c:\tex\pxl6\@Rr\,}@f{.pk}
%/pg={,$DVIDRVGRAPH:}{@Rrdpi\,}@PBf{@Ef,.msp,.pcx,.bmp}
%/ps=t:\dat\esub.fnt
/pv={.,.\lofo\,\tex\vf\}@f.vf
/pm={.,..,lofo,..\lofo,c:\pf\{q,x}\tfm,t:\tfms\{ta,tc,ga,ps}}\@f{.tfm}
% transcript:
/pt=
% +unit & +ruler-unit:
/u=cm
/ou=cm
% +scaling:
/s3
%% graphic card
%/oa=
/fl=-1
% color defaults: 2 1 2
%/ocp=2
%/ocr=7
%/ocs=14
% don't use EMS, only XMS:
/xe-
% +inverse:
/oi+
/r=300
/rf=300
/fs=1
/fd=2
/h=29.7
/w=21
% batch mode:
/fb
% MF mode:
/fm=hplaser
% Name of the data for MFjob:
/pj=gentemp.mfj

>>>>>>>>>>>>>>>>>>>> EG.CNF >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< PS2PK.AWK <<<<<<<<<<<<<<<<<<<<
# PS2PK automates rendering pfb fonts 
# for emtex screen drivers
#
# encoding we get from psfonts.map
# afm information from afm.file
# pfb information from pfb.file
# fonts/scaling from dviscr.dlg
#
# this script should generate the following line
#@call ps2pk.bat <fontname> <res> <encoding-ifany>

# Get the environment variable from the system 
function env_var(v,    setlist) {
        
   while (("set" | getline  setlist ) > 0) {
        match(setlist,"=");
        vname = substr (setlist,1,RSTART-1);
        if (v == vname) { return (substr (setlist,RSTART+1) )}
   }
   return ("."); # default is current dir
}

BEGIN{ PSCONFIG = "TEXCONFIG"; # env. variable for looking for DVIPSCNF
       DVIPSCNF="psfonts.map"; # DVIPS font configuration file name
       PROGNAME = "@call ps2pk.bat"; # the font generating program 
       GENFILE = "mk-pkfon.bat"; # output file (for results)
}

BEGIN {
    v = env_var(PSCONFIG);
    flag = 0;

    vnum = split(v, vvec,";");
    for (i=1; i<=vnum; i++) {
        filenam = vvec[i] "\\" DVIPSCNF; # full path
        while ( (getline < filenam ) > 0) {
            ## next; <-- bd
            flag = 1;
            break;
        }
        close(filenam);
        if (flag) {break}
    }
}


# Scanning font info from external file (gentemp.mfj)

{
    if ($0 ~ "font") {
       print "->";
       gsub("[{};=]", "");
       FONTNAME = $1; sub("font","",FONTNAME);
       FONTRES = $2;  sub("mag","",FONTRES);

       enc = ""; # default is built-in encoding

       print FONTNAME;

       while ( (getline tmp < filenam ) > 0) {

          x = split(tmp, finfo, " ");

          if (finfo[1] == FONTNAME) { 
             if (tmp ~ "ReEncodeFont") {
                enc = finfo[x-1]; 
                enc = substr(enc,2);
             }
             print PROGNAME, FONTNAME, int((FONTRES * mode) + 0.5), enc > GENFILE;
          }
       }
       close(filenam);
    }
}


>>>>>>>>>>>>>>>>>>>> PS2PK.AWK >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< PS2PK3'.BAT <<<<<<<<<<<<<<<<<<<<
@echo off
 echo GENERATING FONTS for 300 dpi
 echo usage: ps2pk3' dvifile
 echo THEN RUN mk-pkfon.bat
 if %1. ==. goto ERROR
 call eg %1
 gawk -v mode=300 -f ps2pk.awk gentemp.mfj
 del gentemp.mfj
:ERROR
>>>>>>>>>>>>>>>>>>>> PS2PK3'.BAT >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< EG.BAT <<<<<<<<<<<<<<<<<<<<
@echo off
if exist eg.cnf goto LOCAL
:GLOBAL
echo y|dviscr @\tex\data\eg.cnf %1 %2 %3 %4 %5 %6 %7 %8 %9
goto END
:LOCAL
echo y|dviscr @eg.cnf %1 %2 %3 %4 %5 %6 %7 %8 %9
:END
if exist 'gentemp.mfj goto MODIF
goto ENDEND
:MODIF
rem call modmfj.bat hp 'gentemp.mfj '%%%%%%%.%%%
rem copy '%%%%%%%.%%% 'gentemp.mfj
rem del '%%%%%%%.%%%
:ENDEND
>>>>>>>>>>>>>>>>>>>> EG.BAT >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< DOW.AWK <<<<<<<<<<<<<<<<<<<<
# DOW funkcja obliczaj/aca dzie/n tygodnia na podstawie podanej daty
#
# (TP, 1995)
#

function chi (x) { if (x > 0) { return 0 } else {return 1 } }

# FUNKCJA dow ----------------------------------------------------------
# argumenty:          y -- rok, m -- miesi/ac, d -- dzie/n (w miesi/acu),  
# np:                 1994,6,12
# zwracana warto/s/c: numer dnia w tygodniu
# ----------------------------------------------------------------------

function dow(y, m, d,           c, i, dy, dw){  
   _DOW[1]="Poniedzia/lek";  _DOW[2]="Wtorek";    _DOW[3]="/Sroda";
   _DOW[4]="Czwartek";      _DOW[5]="Pi/atek";    _DOW[6]="Sobota";
   _DOW[7]="Niedziela";

   c[1] = 31;  c[2]  = 28 + chi(y % 4) - chi(y % 100) + chi(y % 400);
   c[3] = 31;  c[4]  = 30;   c[5] = 31;  c[6] = 30; c[7] = 31; c[8] = 31;
   c[9] = 30;  c[10] = 31;  c[11] = 30; c[12] = 31;

   for (i = 1; i <= m - 1; i++ )
	   dy = dy + c[i];

   dy = dy + d;

   dw = (5+y+dy+int((y - 1)/4) - int((y-1)/100) + int((y - 1)/400)) % 7 +1;
   
   return dw;
}

# Test:
BEGIN {#
print "Grunwald, 14 VII 1410,", _DOW[dow(1410,7,14)];
print "Gettysburg, 1--3 VII 1863,", _DOW[dow(1863,7,1)] "--" _DOW[dow(1863,7,3)];
print "Drezno, 13--14 II 1945,", _DOW[dow(1945,2,13)] "--" _DOW[dow(1945,2,14)];
}
>>>>>>>>>>>>>>>>>>>> DOW.AWK >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< CHKDAT.AWK <<<<<<<<<<<<<<<<<<<<
# Report files with TODAY's date (DOS/GAWK version)
#    usage:   gawk -f chkdat.awk
#
# TP 5.4.96
#
BEGIN {
  flag = 1

  "echo. | date" | getline d; 
  "echo. | date" | getline dmask; 
  gsub("-"," ", d);  split(d, date, " ");
  cyy = substr(date[5],3,2); #
  cmm = date[6];  cdd = date[7];
  
  while ("dir\\/s" | getline) {
    if ($1 == "Directory") {cdir = $3} else {
      if ($0 !~ /^ / && NF > 2) {
        yy = substr($(NF-1),1,2);
        mm = substr($(NF-1),4,2);
        dd = substr($(NF-1),7,2);
        if (yy == cyy && cmm == mm && cdd == dd) { print cdir "\\" $0; flag = 0 }
      }
    }
  }
  if (flag) {print "No today's files" }
  
}
>>>>>>>>>>>>>>>>>>>> CHKDAT.AWK >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< TEST.TEX <<<<<<<<<<<<<<<<<<<<
\font\rm = QPLR
\font\bf = QHVB
\font\it = GRAF203
\font\xx = GRAF203 at 19.9pt
\font\yy = QPLR at 29pt
\rm

\rm q
\it q
\bf q
\xx q
\yy q

\bye
>>>>>>>>>>>>>>>>>>>> TEST.TEX >>>>>>>>>>>>>>>>>>>>
<<<<<<<<<<<<<<<<<<<< FOPEN.AWK <<<<<<<<<<<<<<<<<<<<
#
# fopen -- test if file exist

function fopen(fname,  x) {
   return (getline x < fname) > 0? 1: 0;
}

# Test
BEGIN  {print "fopen.awk ->" fopen("fopen.awk"); }
BEGIN  {print "fopen.xxx ->" fopen("fopen.xwk"); }

>>>>>>>>>>>>>>>>>>>> FOPEN.AWK >>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>> ENDBUNDLEDATA >>>>>>>>>>>>>>>>>>>>
