| |||||||||||
Doubt in this IF-ELSE code Posted by Rukesh (Rukesh), 22 January 2007 Hi friends, I have gone through the following code which is a test script. Here, always else code is getting excuted. Then what is the need of the if-block. if { 0 } { ---do some--- } else { --do some-- } Pls rep me. Thanks in advance. Regards, Rukesh D Posted by admin (Graham Ellis), 22 January 2007 I don't know. What do the comments in the program tell you about it?I'm also puzzled by the syntax - I think you might be posting "pseudocode" there, or some other language? With Tcl, the block with { usually has to start on the same line as the condition, and the } has to be on the same line as the else unless you use continuations. Tell us a bit more about what the comments say, and the actual structure of the code - if the block structure has been changed then perhaps something else has? With what I've seen so far I could only make a guess at what's going on. Posted by Rukesh (Rukesh), 23 January 2007 Hi pal,Thank you for your reply. Here is the code. There was no comments provided. if { 0 } { if { $UDPSrcPort != 1000 } { eval $generatorName seqdefine $TrfcSrc udpBlk -srcPort $UDPSrcPort -dstPort $UDPDstPort $UDPOptString } } else { eval $generatorName seqdefine $TrfcSrc udpBlk -srcPort $UDPSrcPort -dstPort $UDPDstPort $UDPOptString } Put your comments on the above code. Regards, Rukesh D Posted by admin (Graham Ellis), 24 January 2007 I think yuor code IS commented ... I think the if {0} { was added to suspend the operation of part of the logic so that the code that probably took a while to develop is not lost and can be restored to use later. Actually a trick I use quite often .... in PHP, you'll find me writing if (0 == 1) { to do much the same thing This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |