From mboxrd@z Thu Jan 1 00:00:00 1970 From: jtc@redback.com (J.T. Conklin) To: Stan Shebs Cc: gdb@cygnus.com Subject: Re: problem with chained if statements? Date: Thu, 01 Apr 1999 00:00:00 -0000 Message-id: <5m4snj4qv1.fsf@jtc.redbacknetworks.com> References: <199903170011.QAA07805@andros.cygnus.com> X-SW-Source: 1999-q1/msg00134.html jtc> I'm trying to write some user-defined commands to traverse jtc> and/or pretty-print some of the internal data structures used in jtc> our SW. In the absense of a `switch' statement, I am using a jtc> chain of if .. else if ... else if ... else ... end statements. jtc> Unfortunately it doesn't seem to work. Stan> Try: Stan> if ($status == $TASK_READY) Stan> printf "READY " Stan> else Stan> if ($status == $TASK_DELAY) Stan> printf "DELAY " Stan> else Stan> if ($status == ($TASK_DELAY | $TASK_SUSPEND)) Stan> printf "DELAY+S " Stan> I think the else and the if each need to be on their own lines. It turns out to be something like: if ($status == $TASK_READY) printf "READY " else if ($status == $TASK_DELAY) printf "DELAY " else if ($status == ($TASK_DELAY | $TASK_SUSPEND)) printf "DELAY+S " else .... end end end Pretty ugly (IMO). It will suffice as a workaround, but I'll have to look into how difficult adding "true" else-if support will be. Would an `elif' keyword be objectionable? What are the current thoughts wrt. adding a more capable extension language for gdb scripting? --jtc -- J.T. Conklin RedBack Networks