gawk switch

Hi,
i get always the defalut value 1000 in ccode, what could be wrong?
I try: case /string/ also without success.

Thanks for advance
Christian


gawk  -F";" '{ switch ($4) {
case "hello":ccode=1
case "test": ccode=2
and more....
default: ccode=1000 }
}
{print $1,$2,$3,$4,$5,ccode}'
0
chris
1/19/2011 4:51:16 PM
comp.lang.awk 3316 articles. 0 followers. Post Follow

1 Replies
565 Views

Similar Articles

[PageSpeed] 31
Like the C switch, you have to put a break at the end of the code for
each case. Otherwise, control flow falls through to the next one.
This is even documented.

Arnold

In article <f335e50e-ba1e-40d2-8c77-4553ad04c8b6@o4g2000yqd.googlegroups.com>,
chris  <ozric@web.de> wrote:
>Hi,
>i get always the defalut value 1000 in ccode, what could be wrong?
>I try: case /string/ also without success.
>
>Thanks for advance
>Christian
>
>
>gawk  -F";" '{ switch ($4) {
>case "hello":ccode=1
>case "test": ccode=2
>and more....
>default: ccode=1000 }
>}
>{print $1,$2,$3,$4,$5,ccode}'


-- 
Aharon (Arnold) Robbins 			arnold AT skeeve DOT com
P.O. Box 354		Home Phone: +972  8 979-0381
Nof Ayalon		Cell Phone: +972 50  729-7545
D.N. Shimshon 99785	ISRAEL
0
arnold
1/19/2011 5:13:27 PM
Reply:
Similar Artilces: