Suggestions regarding ARGV and folding of lines



HI all,

I've been reading the c.l.a. for some time now, and I found out many
useful messages, and interesting sites through this group. This is my
first post though. I have a working script, but would like to get a
few answers from more experienced awkers. I will post a script and
input, and then ask the questions.

find.awk:

BEGIN{
if(ARGC != 2){ print "Enter word to find translation for!"; qrac=1;
exit }
FS = "[#|]"
while(blabla++<=48)
spaces = spaces " "
while(habahaba++<105){
dashes = dashes "-"
dashes2 = dashes2 "="
}
findMe = ARGV[1]
ARGC--
ARGV[ARGC++] = "./reci.dat"
}

{ if($2 ~ findMe) {
if($0 ~ /^Sr#/){
csr++
ser[$2] = $3
}else{
cen++
eng[$2] = $3
}
}
}
function PrintHeader(){
print "\n"
print dashes2
printf("| %-48s | %-50s | \n", "Searched word", "Translation")
print dashes2
}

function ckL(word){
if(length(word)<=50)
return word substr(spaces, length(word))
else{
wordPart = substr(word,51)
return substr(word,1,50)" | \n| " spaces "| " ckL(wordPart)
}
}
END{
if(!qrac){
if(!cen)
print "\n\tNo word in English."
else {
PrintHeader()
for(i in eng) {
gsub(/-/, ", ", eng[i])
printf("| %-48s | %-48s |\n", i, ckL(eng[i]))
print dashes
}
print "\n"
print "\Found: ", cen, "translations from English."
}

if(!csr)
print "\n\tNo word in Serbian."
else {
PrintHeader()
for(j in ser){
printf("| %-48s | %-48s |\n", j, ckL(ser[j]))
print dashes
}
print "\n"
print "\Found: ", csr, "translations from Serbian."
}
}
}


Is it safe to use: findMe = ARGV[1]; ARGV[1] = "./reci.dat" and don't
touch ARGC, or the above is the "right way"? Both ways work, I just
want to know whether I could expect some troubles using either.

Second question is about folding of lines; I'm using ckL() function to
check for field length and then print spaces and the word. Is there a
better/simpler/more readable way? The widest field $2 is 252
characters long.

Thanx and sorry for a bit lengthy post.

All best


P.S. File reci.dat is just a text file containing entries like this (i
trimmed it as I can't attach files, it's 2.3MB file):

reci.dat:

En#Settlement Of A Bill|Izmirenje Racuna
En#Settlement Of Contract|Izvrsenje Ugovora-Placanje Ugovorene Cene
En#Settlement Of Disputes|Resavanje Sporova
En#Settlement Of Loss|Poravnanje Stete
En#Settlement|Selo-Seoce-Naselje-Resenje-Pogodba-Namirenje-
Kolonizacija-Uredjenje-Izravnjanje-Naredba-Naseljenje-Naseobina-Odluka-
Sleganje-Ugovor
En#Settler|Naseljenik
En#Settle|Osloboditi-Nastaniti Se-Smestiti Se-Naseliti-Sesti-Namestiti
Se-Dogovarati-Praviti-Isplatiti-Spustiti Se-Namiriti-Odluciti-Resiti-
Slegati Se-Sleci Se-Srediti-Urediti-Ustanoviti
En#Settling Basin|Taloznik
En#Settling|Istalozavanje
En#Sett|Kaldrma-Kamene Kocke
En#Setup Time|Vreme Pripreme
En#Setup|Maketa-Uredjaj-Postavljanje-Podesavanje-Sema-Struktura-Plan-
Priprema-Organizacija-Lak Posao-Prevara-Uredjenje-Zadatak
En#Set|Namesten-Postaviti-Namestiti-Urediti-Zgusnuti Se-Prionuti-
Pripremiti-Zaci-Pros. Od Set-Garnitura-Odredjen-Propisan-Stalan-Cvrst-
Skup-Grupa-Komplet-Serija-P.Pr. Od Set-Mnostvo-Nakititi-Odrediti-
Odrezak-Poloziti-Posaditi
En#Sevedge|Rub Tkanine
En#Seven-Segment Display|Sedmosegmentni Zaslon
En#Sevenfold|Sedmerostruk
En#Seventeenth|Sedamnaesti
En#Seventeen|Sedamnaest
En#Seventh|Sedmi
Sr#Sest|Six
Sr#Setaci|Parade
Sr#Setac|Walker
Sr#Setalica|Pendulum
Sr#Setaliste|Parade-Promenade-Boulevard-Mall
Sr#Setanje|Promenade
Sr#Setan|Mopish-Sad-Dismal
Sr#Setati Se|Walk-Perambulate
Sr#Setati|Perambulate-Go-Promenade
Sr#Setiti Se|Recur-Mind-Recall-Recollect-Remember
Sr#Setnja|Turn-Sally-Hike-Jaunt-Promenade-Ramble-Round-Ride-Stroll-
Saunter
Sr#Sevanje|Shaft-Burst-Twinkle
.