Re: Hi

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Sat, 16 Jan 1999 14:33:30 -0500, Ken Furlong <stjohn15 at ENTER.NET> wrote:

>Hi, my name is Ken Furlong, I just downloaded Euphoria and signed up for
>the mailing list.  I thought I'd take a minute to intoduce myself.  I'm
>just an ameture programer who aspires to be a pro someday.  I've had a
>little experience in QBasic and Borland C++.
>
>I had a question, in QBasic and C++, you can name blocks of code so that
>you can go to them from, say, an if-then statment instead of writing the
>whole thing out under the if-then.  I think in QBasic you use Gosub.  I
>was wondering if there was an Euphoria version of the Gosub command.
>

Hi Ken, and welcome.

Gosub in basic is just a subroutine call.
If you have no parameters to pass, you can replace it with
a procedure. Example:

if balance < 0 then gosub Overdrawn <-- basic
if balance < 0 then Overdrawn() <-- euphoria
end if

if you need to get a return value, then use a function:
balance = Sum(4,6,8)

Just remember that the procedures and functions MUST be declared
before they can be called! This is normal procedure for many languages,
but not necessarily for all.
Example:
procedure Overdrawn()
  puts(1,"Oh,oh, your account is overdrawn!');
end procedure -- this returns automatically when done

function Sum(sequence s)
atom total
  total = 0
  for i = 1 to length(s) do
    total = total + s[i]
  end for
  return total
end function

balance = Sum(3,44,7,-23,-55) -- note: upper and lower case counts!
if balance < 0 then Overdrawn() -- sum is not the same as Sum or SUM
end if

There is not a goto in Euphoria, nor is one needed.

HTH
Irv

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu