gawk switch

  • Permalink
  • submit to reddit
  • Email
  • Follow


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
Reply chris 1/19/2011 4:51:16 PM

See related articles to this posting

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
Reply arnold 1/19/2011 5:13:27 PM
comp.lang.awk 3169 articles. 6 followers. Post

1 Replies
383 Views

Similar Articles

[PageSpeed] 14

  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

My switch is not switching
Hi, To handle a custom protocol over a serial line I am trying to implement a very small and simple state machine. The states are declared as enum: enum CommState { CS_WAIT_FOR_STX, CS_WAIT_FOR_T, CS_WAIT_FOR_0, CS_WAIT_FOR_Key, CS_WAIT_FOR_ETX }; I wanted to switch on the current state and handle whatever needs to be done in that state plus the transition to the next one. However, my switch() is always falling through to the default case. I have cut down my code to this nonsensical example: CommState commState=3DCS_WAIT_FOR_STX; if (commState=3D=3DCS_WAIT_FOR_STX) { s...

Raritan SwitchMan keeps on switching and switching and switching.......
I finally have what I wanted (almost) here in my office........ I have an old Gateway hybrid on the desk behind me as a complete backup netsurfer, etc. Today I hooked up the Gateway and PowerPC to a Raritan SwitchMan.....running Windows 98SE on the Gateway and AIX 4.3.3 on the Power PC and it works like it had eyes! Thanks to you all for your suggestions, with a special thanks to WBST for ushering me into the SwitchMan Scenario.......... Now for the big question: Ta Daaaaaaaaaaah.......... I have an open PCI slot which seems the obvious place for a modem. Is this plausible? ...

Switch Within A Switch
Hello, I am working on an Adobe Acrobat file that uses javascript for calculations. I am trying to create a field that uses two other fields to determine a number value. I think this requires a switch within a switch, but I am not sure how to do this, as I am a beginner when it comes to javascript. In esscense, I want to set up a code so that each case of value A is calculated at each case of value B. Example: There are 9 cases for value A. There are 30 cases for value B. I want to produce a number at each value B for each case in value A. I hope I have explained what I want to do well e...

switch to switch link
I got a 4506 with a supervisor II+module with to GBIC ports. one GBIC port goes to a core type switch which is currently enabled with the cisco-switch macro switchport trunk encapsulation dot1q switchport mode trunk switchport nonegotiate udld port aggressive auto qos voip trust macro description cisco-switch spanning-tree bpduguard disable spanning-tree link-type point-to-point Both ends are set to trunk mode. On the same 4506, the second gbic port goes to another 4506. Since this other 4506 does not connect directly to the core switch, what mode should i be setting this port ...

additional switch for switch?
Hello, in the younger past, I read, that switch only does string comparisons. In many cases switch could work with numerical values, so why not introducing a new switch (better option) for switch? What's about: % proc Name {args} { global names; set numValue [llength $args]; switch -numerical -- $numValue { 1 {return names([lindex $args 0]);} 2 { foreach {object name} $args {break;}; return [set names($object) $name]; } default { error "wrong # args: should be \"Name object ?name?\""; ...

2950 switch to switch question
hi all how can i use straight through cable to connect two 2950 switches? thanks steve 2950 requires a crossover to another 2950. 2960 is auto-polarity sensing. "STandard" <standardhk@gmail.com> wrote in message news:1184729741.090916.195460@z28g2000prd.googlegroups.com... > hi all > > how can i use straight through cable to connect two 2950 switches? > > thanks > > > steve > > On Jul 17, 11:35 pm, STandard <standar...@gmail.com> wrote: > hi all > > how can i use straight through cable to connect two 2950 switches? > ...

adding a switch to a switch stack
i am adding a switch to a 3750 switch stack that already has 2 switches in it. I am also running vtp in the network. I believe if i add this new switch i will not have to concern myself with vtp(joining it to the domain and adding the switch in transparent mode). Since this would be controlled and set in the master switch in the stack. Just confirming this. Thanks Correct, This switch will not be seen as a separate switch at all but sort of like a module on the already existing switch. If properly set-up of course. CYA On 2/26/08 6:43 PM, in article 30b2ccac-9b57-40ac-965f-a483958f21c2...

Switch Color To Monochrome Switch?
The Apple IIgs' Control Panel has the feature to switch from Color to Monochrome for DHGR. Do it have in $C0XX as softswitches? I can't find in the manual. Do you know? I do not have to go through Control Panel. Bryan Parkoff Bryan Parkoff wrote: > The Apple IIgs' Control Panel has the feature to switch from Color to > Monochrome for DHGR. Do it have in $C0XX as softswitches? I can't find in > the manual. Do you know? I do not have to go through Control Panel. $c021 bit 7 is the color/mono select (bits 6..0 are reserved) According to page 83 of the I...

MRTG and switched off-switched units
Hi, i monitor an CPU-Load with MRTG, but if the computer, wich is monitored, is switched off, after a while mrtg produces "1" in the logfile. I use unknaszero to get a straight line, if the computer is switched off. Any ideas, how i ever get a "0", if the unit is powered off? thy, rene -- | 6. Chemnitzer Linuxtag - http://www.tu-chemnitz.de/linux/tag/ | | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | | Rene Caspari - http://reca.ahrcas.net | | EastLink GmbH - http://www.eastlink.de | ...