MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Goto/Conditional Loops?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg2877] Re: [mg2853] Goto/Conditional Loops?
  • From: Jesus ROJO <jesroj at wmatem.eis.uva.es>
  • Date: Thu, 4 Jan 1996 03:04:25 -0500

Your message:
> 
> Hi! I've been working at this program for a while and seem to be having a 
> problem that I can't seem to see.
> I have a small conditional loop that works:
> 
> Label[skip];
> Clear[question];
> y:=Input["question"];
> If[question==y , Print["yes"];Goto[skip],Goto[dnskip]];
> Label[dnskip];
> Print[dnskip];
> 
> . . .  (deteted lines) 
> 
> I'd greatly appreciate all and any help.
> Thanks.
> Andre
> 

Hello,

Some time ago I sent a message to Technical Support
of Mathematica with (more o less) the same subject
that interest you. I sen you my question and their
answer.

Sincerely,
			 Jesus ROJO 

==========================================================
My question:

	    License Number  L2133-4000



Hello,

I find, when using Mathematica, the followng programming 
problem: The instruction 'Goto' cannot be used to jump
out of a loop 'Do'.

For example, the following programme here shown
in a summarized form:

     variable[arguments_]:=Module[{ ... },
     .....................................
     Do[
     .....................................
     Goto[end];
     .....................................
     ,{i,1,5}];
     .....................................
     Label[end];
     .....................................
     ] (* end of Module *)

alwais gives me the following error message:

     CompoundExpression::::goto: Label[end] requested by Goto not found.

I naturally find ways to get round it, but I would
like it to function as expected (for example,
as in FORTRAN).

Is this correct ?  Is there any way to correct it ?

				    Jesus ROJO

============================================================
Their answer:

Dear Jesus Rojo,

You are correct in stating that the Goto[] will function within a
loop or block of statements, but it will not look outside of that
loop or block for a label.

There currently is not a workaround.  Our developers are aware of the
problem, but I'm not sure how much progress will be made on it, as the
philosophy and structure underlying the Mathematica language don't lend
themselves well to global Goto statements.  We do provide the Throw and
Catch commands (on pages 294-5 of the Mathematica book) for a more
global response, if you're interesting in looking at that.

Thank you for your question.  I'm sorry I couldn't be of more help.

Sincerely,

John Fultz
Technical Support
Wolfram Research, Inc.

--
---------------------------------------
|  Jesus ROJO                         |
|  Dpto. de Matematica Aplicada       |
|  E.T.S. de Ingenieros Industriales  |
|  Paseo del Cauce s/n                |
|  47011 VALLADOLID, Spain            |
|  Phone : 34 - 83 - 42 33 90         |
|  Fax   : 34 - 83 - 42 34 06         |
|  e-mail: jesroj at wmatem.eis.uva.es   |
---------------------------------------


==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Re: Should I get Matlab or Mathematica or ?
  • Next by Date: Re: Goto/Conditional Loops?
  • Previous by thread: Re: Should I get Matlab or Mathematica or ?
  • Next by thread: Re: Goto/Conditional Loops?