Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
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---
  --do some--

Pls rep me.  
Thanks in advance.

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.

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 and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho