Sorry for setting my foot as just a technical user on holy ground here again asking and learning. After tries with strings and arrays I decided to go for an if-else-if-ladder for a database, just because it looks a little easier to me, but as it happens, my result is not the desired one.
So here is the scheme for the if-else-if-ladder in awk. Given a database.txt with four rows, the fourth one is my aim.
The last two lines of the database.txt
webster 3:48, 29.06.2014 Jun
webster 3:50, 29.06.2014 Jun
That's the scheme for the if-else-if-ladder
if(conditional-expression1)
{action1 ; action 2;}
else if(conditional-expression2)
{action1 ; action 2;}
else if(conditional-expression3)
{action1 ; action 2;}
.
.
else
action n;
That's my first step into it.
#declaring myarray as row four with the months
awk '(string["JanFebMarAprMayJunJulAugSepOctNovDec"]=$4);
#defining mysubstring to be substring(named submonth) of string with startposition and length
mysubstring=submonth[string("JanFebMarAprMayJunJulAugSepOctNovDec",1,3)],
#guess here my trouble starts, no matter what if-condition, the interpreter complains about a syntax error
#it should start in row four, position one, maximumlength, matching for example [Jun]
#choosing submonth as a term, because substring is a named function
#so I put the following line, not sure about it, 'cause it doesn't work
b=split(submonth,array,search)
search="submonth"
(mysubstring($4,1,3)==submonth[Jun])
#and by now it gets something like a for-condition rather then the if-else-if-ladder
#followed by the two actions.
($4>max) max==$4 {OFMT="%6f"; ORS ":"; print max; sum=sum+$4};
{OFMT="%-7.4f\n"; ORS ":"; print sum/NR} ; ' database.txt
but the sad thing stdout tells me something like this: There is no function for string defined. How to define it? I guess it would be split. While setting split, the interpreter tells me that 'search' still is no definiton for the string.
Can anybody give me a hint on that, regards and thanks in advance.