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 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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.

You can Add a comment or ranking to this page

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