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 3204 articles. 6 followers. Post

1 Replies
412 Views

Similar Articles

[PageSpeed] 37


  • 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?\""; ...

help for switch to switch connection
Hi all, i have two 2950 switches, and i wanna to connect them with a Straight- Through cable. i know it should be easy to fixed by using cross cable, but my case is not easy to re-install cross cable =( so any idea, or can it be config a uplink port for one 2950 switch? thanks steve In article <1184727739.487187.124580@e9g2000prf.googlegroups.com>, STandard <standardhk@gmail.com> writes: > Hi all, > > i have two 2950 switches, and i wanna to connect them with a Straight- > Through cable. > > i know it should be easy to fixed by using cross cable, but my ...

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 | ...

Switching a switch via CDF
Hi, about a year ago, I asked how to switch a sp*tswicth from analogLib and got an answer with a workaround from Andrew. I now write an OCEAN script which is supposed to be started from icfb so I can use some of the icfb specific functions described. Now I have been playing with some cdf* Skill functions and wonder if it is possible to change the value of a CDF field. What I have done so far is: design( "lib_bjerkem" "circuit_tb" "schematic") target = ddGetObj( "analogLib" "sp1tswitch" ) user = cdfGetBaseCellCDF(target) now I can see some ...

Connecting a switch to another switch
Recently we connected few computers using a switch and we have another network which has another switch. We want to connect these two networks. How could this be done. Please suggest. Thanks in Advance Maisheri "Maisheri" <maisheri_hitesh@rediffmail.com> wrote in message news:4e25fc0e.0408122355.4b2c6490@posting.google.com... > Recently we connected few computers using a switch and we have another > network which has another switch. We want to connect these two > networks. How could this be done. Please suggest. > Thanks in Advance > > Maishe...

Binary switching logic versus rotary switching 1 to n position switching logic.
Binary switching logic versus rotary switching 1 to n position switching logic. Anybody interested in implementing rotary switching 1 to n position logic in hardware software or firmware? Interesting possibilities lie ahead. On Aug 17, 4:24=A0am, Ian Martin Ajzenszmidt <iajzens...@gmail.com> wrote: > Binary switching logic versus rotary switching 1 to n position > switching logic. Anybody interested in implementing rotary switching 1 > to n position logic in hardware software or firmware? Interesting > possibilities lie ahead. 1 to n rotary switching logic means any number ...

GAWK
am using GAWK(windows), i want to list files in a current directory & i want to redirect all the listing files to a file hw can i do it.......................? pls reply.... On 1 Mar 2007 04:24:48 -0800, gvarvind@gmail.com wrote: >am using GAWK(windows), i want to list files in a current directory & >i want to redirect all the listing files to a file hw can i do >it.......................? pls reply.... The only way to use gawk to do this is to wrap it around a shell command - however, there are a wide variety of options for generating the list, and of course processing it...

Switch
Ok, been pondering switch from Gatesworld over to Mac. Just getting fed up with the amount of hacking and viruses assocated with XP, Outlook and IE So, does Mac have some of the same problems online? Viruses coming in through email all the time, spy ware/ad ware self installing, etc...? What about my PC based file - Photoshop, Illustrator, Word, etc... What happens to those in a switch? I want to try to find a good used G4, along with a cuple older eMacs for the kids - anything to watch out for? In article <97d4a07.0407291655.5f05477f@posting.google.com>, karl@shadowlakes.com (Deser...

switch
List, Python does not have switch statement. Any other option does similar work? Thanks for help. --henry ...

gawk
How do I get this to print the line ony once rather than 4 times? gawk 'BEGIN{id = ""; barcode = ""} { if (NR%4==1) {id=$0} else if (NR%4==3) {barcode=substr($0,4,14)} } {print bid" "barcode}' thanks 2004-06-24, 13:46(+00), tony: > How do I get this to print the line ony once rather than 4 times? > > gawk 'BEGIN{id = ""; barcode = ""} > { > if (NR%4==1) {id=$0} > else if (NR%4==3) {barcode=substr($0,4,14)} > } > {print bid" "barcode}' [...] gawk 'BEGIN{id = ""; barcode = &qu...

Switch
Just pull the black plastic top of the switch.. Then pull the contact plate out..(tweezers).. The backlight will work. Of course it wont go into hibernation when you close the lid.. (If thats what you have you settings set to).. But the backlight will work. This is a simple push spring retension return mechanism or rocker contact plate switch.. Its nothing to do with hibernation mode on the laptop.. ...

Switch
what is the use of switch in programming C? On Apr 29, 9:04=A0am, nafiz....@gmail.com wrote: > what is the use of switch in programming C? switch() helps you make a decision based on many tests for example you dont have to test the equality on and integer to another with a if- else if-else structure , you may instead use a switch statement like switch(c) { case 1: //do stuff break; case 2: //other stuff break; default: //etc } so it tests the equality of integers "ONLY INTEGERS" and expressions that can...

switch
In a switch statement must a supply a default or what is the default by default? Is switch(foo) { case 1: return 1; default: break; } the same as switch(foo) { case 1: return 1; } Thanx, Christopher Christopher wrote: > In a switch statement must a supply a default or what is the default > by default? You supply one if you want to. If you do not supply one then if none of the labels match the switch will be "ignored", meaning that it means what you just wrote below: > switch(foo) > { > case 1: > return 1; > default: > bre...

Switch
Hi, does it makes sense to have 3 network cards connected to one same 24 port switch? Will this improve performance or a waste of resources? I'm running IPX. ...

switch
taken from how stuff works "When one animator sends a file to another, the very large file will use up most of the network's capacity, making the network run very slowly for other users. One of the reasons that a single intensive user can affect the entire network stems from the way that Ethernet works. Each information packet sent from a computer is seen by all the other computers on the local network. Each computer then examines the packet and decides whether it was meant for its address. This keeps the basic plan of the network simple, but has performance conse...

Switch
I wrote a PHP script that the user decides who they want to send the email to based on the selection from a "dropdown" box. The essential part of the script that I'm having problems with is: <?php /* Pre-defined script variables. */ $eol = "\n"; $mailto = 'me@mycorp.net'; $mailfrom = 'webserver@mycorp.net'; $subject = 'Contact Us Request'; /* Initialize a clean array to replace $_POST with clean data */ $etype = $_POST['etype']; $errmsg = 'etype-: '.$etype.' | Case value-: '; /...

Switch
Just having installed a Mitel 3300 VOIP box I am looking for switch recommendations This is going into a new building and I was going to keep the voice and data separate. As I am now in a position to be able to purchase some switches I thought I may install the QOS type and mix the voice and data together. This is only a small installation as cost was an important factor (24 Users) Any recommendations ?? Should I get ones with power ??? By 'switches,' I guess you mean Ethernet switches. If so, this is a personal choice. You said you were trying to keep co...