1. Dumb question by a beginner
- Posted by Jerry Shirey <IsaacJBS2 at AOL.COM>
May 01, 1999
-
Last edited May 02, 1999
Hey everyone. I just started with Euphoria (got tired of struggling with C
and C++) and I'm basically a rookie here. The reason I had trouble with
C/C++ was that I was able to get the compiler to do what I wanted less than
half the time, no matter how many examples I explored! And basically,
screwing around with simple code is how I get a grasp of a language and learn
to use it for myself.
Well, I've been reading the documentation, and now I'm trying to get simple
routines to run - ones that originate completely from myself. Right now, I'm
tinkering with functions and procedures, so forth.
Here's one I'm sure everyone understands but me.
I don't seem able to
find any directions, or examples that I can fathom, of how to pass
information back and forth between functions, or from the main program to a
function and back again.
As I understand it, a EU procedure is when you don't need any information
returned to the rest of the program, while a function is used when you do.
I'm not clear on what the uses there are for a procedure if all you can do is
pass it a value, have it work on the information, then get nothing back
(which makes me question my understanding of it).
But regardless, my experiments with functions have only yielded me errors.
When I look at other programs, I don't quite see how the main program is
passing information to the function, nor do I see how the main program is
receiving this information back - where does it store the data, etc.. So
then, how do I correctly pass this sort of information back and forth between
procedures/functions? Perhaps someone could send me some simple code, and
tell me what the assignments actually are in the example, since I'm not
getting it from the existing examples I've seen?
Perhaps I'm just not reading the documentation correctly, or I'm
overlooking some existing examples. There seems to be some hole in the
documentation and such that comes with EU, to me. Which, again, makes me
wonder what I'm missing. I also don't seem able to locate any index of error
codes and messages.
THANKS to everyone and anyone in advance. I hope to be contributing to the
group soon, if I can move beyond the realm of "trying to get a basic
understanding..."
Hopefully, I won't be asking too many more easy ones.
IsaacJ
2. Re: Dumb question by a beginner
- Posted by Bernie Ryan <bwryan at PCOM.NET>
May 01, 1999
-
Last edited May 02, 1999
Look in the archives and docs there are lots of examples.
When you get look at a program.
First you will see include files these are same as header files in cpp.
Each variable, function, and procedure has to be defined or dedclared
before it can be used.
Some are defined in your include files the rest are define in your
program before you use them.
Each procedure and function can used as you go towards the end
of the program.
In other words there is no main function just the fact that you
have accomplished what you wanted to by the time you have reach
the end of your program.
Now if you will follow a program from start to end you will get
the idea.
Hope this helps
bernie
3. Re: Dumb question by a beginner
- Posted by David Cuny <dcuny at LANSET.COM>
May 01, 1999
-
Last edited May 02, 1999
Jerry Shirly wrote:
> Here's one I'm sure everyone understands but me.
I don't seem able
to
>find any directions, or examples that I can fathom, of how to pass
>information back and forth between functions, or from the main program to a
>function and back again.
The Euphoria documentation assumes that you have some grasp on basic
programming. Your questions would seem to indicate that you don't. I don't
mean that to be insulting - everyone has to start somewhere. It's probably
best to get your hands on a good introduction to programming book - Basic,
C, Pascal - whatever language, it shouldn't matter too much - and go through
the first couple of chapters.
> As I understand it, a EU procedure is when you don't need any information
> returned to the rest of the program, while a function is used when you do.
Make that "any information returned to the *caller*", since procedures and
functions can call other procedures and function as well.
>I'm not clear on what the uses there are for a procedure if all you can do
is
>pass it a value, have it work on the information, then get nothing back
>(which makes me question my understanding of it).
Let's say you want to make a beeping noise for 10 seconds with the
(imaginary) 'beep' procedure:
beep( 10 )
There's no information for 'beep' to return (other than perhaps that it
failed). Or you want to set a pixel on the screen with the (imaginary)
routine setPixel:
setPixel( 100, 100, GREEN )
Or let's say you wanted to print a line of text with the (imaginary)
printText procedure:
printText( "Hi there!" )
Again, there is no need for the procedure to return information. These are
typical procedures.
> But regardless, my experiments with functions have only yielded me
errors.
What sort of errors? Posting an example with an explanation of what you
intended the code to do might be helpful.
>When I look at other programs, I don't quite see how the main program is
>passing information to the function, nor do I see how the main program is
>receiving this information back - where does it store the data, etc..
As Jerry mentioned, there is no "main" procedure in Euphoria. Code is
executed as it is read. For example, if your file was:
puts( 1, "example program\n" )
for i = 1 to 3 do
? i
end for
Then when you ran the file, you would get the output:
example program
1
2
3
Unlike C, there is no 'main' in sight.
>then, how do I correctly pass this sort of information back and forth
between
>procedures/functions?
OK, here is an example program:
-- example program
-- example of a procedure
procedure proc( integer n )
printf( 1, "the number %d was passed to proc().\n", {n} )
end procedure
-- example of a function
function func( integer n )
-- returns n+1 back
printf( 1, "the number %d was passed to func().\n", {n} )
return n+1
end function
-- define a variable to store the result sent back by the function
integer result
-- set up a loop
for i = 1 to 10 do
-- call the procedure
proc( i )
-- call the function, storing the result
result = func( i )
-- display the result returned from the function
printf( 1, "the number %d was returned by func().\n", {result} )
-- display a blank line
puts( 1, "\n" )
end for
Of course, if you wanted a 'main' routine, try this:
-- example program with a 'main'
-- example of a procedure
procedure proc( integer n )
printf( 1, "the number %d was passed to proc().\n", {n} )
end procedure
-- example of a function
function func( integer n )
-- returns n+1 back
printf( 1, "the number %d was passed to func().\n", {n} )
return n+1
end function
-- main routine
procedure main()
-- define a variable to store the result sent back by the function
integer result
-- set up a loop
for i = 1 to 10 do
-- call the procedure
proc( i )
-- call the function, storing the result
result = func( i )
-- display the result returned from the function
printf( 1, "the number %d was returned by func().\n", {result} )
-- display a blank line
puts( 1, "\n" )
end for
end procedure
-- call the main procedure
main()
That example is essentially the same as the prior example.
Hope this helps!
-- David Cuny
4. Re: Dumb question by a beginner
- Posted by Grape Vine <chat_town at HOTMAIL.COM>
May 01, 1999
-
Last edited May 02, 1999
>From: Jerry Shirey <IsaacJBS2 at AOL.COM>
>Reply-To: Euphoria Programming for MS-DOS <EUPHORIA at LISTSERV.MUOHIO.EDU>
>To: EUPHORIA at LISTSERV.MUOHIO.EDU
>Subject: Dumb question by a beginner
>Date: Sat, 1 May 1999 20:43:55 EDT
>
> Hey everyone. I just started with Euphoria (got tired of struggling
>with C
>and C++) and I'm basically a rookie here. The reason I had trouble with
>C/C++ was that I was able to get the compiler to do what I wanted less than
>half the time, no matter how many examples I explored! And basically,
>screwing around with simple code is how I get a grasp of a language and
>learn
>to use it for myself.
> Well, I've been reading the documentation, and now I'm trying to get
>simple
>routines to run - ones that originate completely from myself. Right now,
>I'm
>tinkering with functions and procedures, so forth.
> Here's one I'm sure everyone understands but me.
I don't seem able
>to
>find any directions, or examples that I can fathom, of how to pass
>information back and forth between functions, or from the main program to a
>function and back again.
> As I understand it, a EU procedure is when you don't need any
>information
>returned to the rest of the program, while a function is used when you do.
>I'm not clear on what the uses there are for a procedure if all you can do
>is
>pass it a value, have it work on the information, then get nothing back
>(which makes me question my understanding of it).
> But regardless, my experiments with functions have only yielded me
>errors.
>When I look at other programs, I don't quite see how the main program is
>passing information to the function, nor do I see how the main program is
>receiving this information back - where does it store the data, etc.. So
>then, how do I correctly pass this sort of information back and forth
>between
>procedures/functions? Perhaps someone could send me some simple code, and
>tell me what the assignments actually are in the example, since I'm not
>getting it from the existing examples I've seen?
> Perhaps I'm just not reading the documentation correctly, or I'm
>overlooking some existing examples. There seems to be some hole in the
>documentation and such that comes with EU, to me. Which, again, makes me
>wonder what I'm missing. I also don't seem able to locate any index of
>error
>codes and messages.
>
> THANKS to everyone and anyone in advance. I hope to be contributing to
>the
>group soon, if I can move beyond the realm of "trying to get a basic
>understanding..."
> Hopefully, I won't be asking too many more easy ones.
>
>IsaacJ
HIya.. I had problems like this too at fiirst but i found that its a liot
like QBasic(sorry if anyone takes that as a insult) ... if you have icq we
can chat and i can explain thing's better....
Grape
icq num 13728824
here are a few pages to help you
http://m2.aol.com/FilesEu/
http://www.cdc.net/~lhilley/
Grape Vine
_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com
5. Re: Dumb question by a beginner
- Posted by Greg Phillips <i.shoot at REDNECKS.COM>
May 01, 1999
-
Last edited May 02, 1999
Although David Gay doesn't support it anymore, as witnessed by his
webpage (http://www.geocities.com/SiliconValley/Vista/4346/), a great
resource for questions like this is his 'A Beginners Guide to
Euphoria'. It isn't availiable for download anymore, but it is an
excellent tutorial that'll get you started in no time. Should you want
it, email me, and I can send it to you. Keep in mind, however, that
it's current to version 1.5, *not* version 2.1. Some newer features,
including Win32 support weren't part of version 1.5, but all the basics
are in there.
Thank you,
Greg Phillips
6. Re: Dumb question by a beginner
I have the second version. I would attach it, but hotmail is acting up.
Go here to get it
Later,
PicklJuic
_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com
7. Re: Dumb question by a beginner
Hi Jerry
I'm just figuring this myself, so it'll help me to try to explain.
Here's a function:
function foo(sequence a, atom b)
sequence c
c=a*b
return c
end function
It would be called by this
sequence a,b
atom c
a={}
b={1,1}
c=2
a=foo(b,c)
We'd end up with a={2,2}
In "a=foo(b,c)" "foo" is the function call, and b and c are the parameters
that are passed to it. A sequence c is returned by the function, and is
placed in the "a" of "a=foo(b,c)" . You can only pass one variable back from
the function, but since it can be a sequence, you can pack anything you want
into it, and then unpack it when it is returned to the code doing the call.
I think it's pretty cool.
I use procedures for things like drawing an image, that don't have to have
anything returned. I remember spending a very frustrating few hours trying
to get values out of procedures. All part of the fun.
Hope I've not confused too much.
Bye
Martin
8. Re: Dumb question by a beginner
I just wanted to thank everyone for all the help. I'm not a total newby -
I'm familiar with several implementations of Basic (though most were a long
time ago), and have some understanding of C/C++. So I thought Euphoria would
be a good place to go to next. I've just started with EU last week and
registered my copy, so I'm trying to get all the basics down before I start
working on anything useful. I found that while it's similiar to languages
more powerful than Basic - like C - that it makes more sense to me, with a
few small exceptions like functions.
Anyway, thanks for all the help.
Isaac
9. Re: Dumb question by a beginner
- Posted by Dan <dhathy at OPERAMAIL.COM>
May 13, 1999
-
Last edited May 14, 1999
On Sat, 1 May 1999 23:31:03 -0700, Greg Phillips <i.shoot at REDNECKS.COM>
wrote:
>Although David Gay doesn't support it anymore, as witnessed by his
>webpage (http://www.geocities.com/SiliconValley/Vista/4346/), a great
>resource for questions like this is his 'A Beginners Guide to
>Euphoria'. It isn't availiable for download anymore, but it is an
>excellent tutorial that'll get you started in no time. Should you want
>it, email me, and I can send it to you. Keep in mind, however, that
>it's current to version 1.5, *not* version 2.1. Some newer features,
>including Win32 support weren't part of version 1.5, but all the basics
>are in there.
>
>Thank you,
>Greg Phillips
To Greg Phillips,
If you could email me a copy of the tutorial,
that would be great.
I too am a newby and am looking to learn how to program.
Thanks in advance for your help.
Dan
Richard Daniels Music - Theory for the Serious Musician
http://www.ncp.net/rdm
10. Re: Dumb question by a beginner
Dan writes:
>Greg Phillips writes:
>> a great
>>resource for questions like this is his 'A Beginners Guide to
>>Euphoria'. It isn't availiable for download anymore, but it is an
>>excellent tutorial that'll get you started in no time. Should you want
>>it, email me, and I can send it to you. Keep in mind, however, that
>>it's current to version 1.5, *not* version 2.1. Some newer features,
>>including Win32 support weren't part of version 1.5, but all
>> the basics are in there.
>>
>>Thank you,
>>Greg Phillips
>To Greg Phillips,
> If you could email me a copy of the tutorial,
> that would be great.
> I too am a newby and am looking to learn how to program.
David Gay's "Beginner's Guide to Euphoria" is in
the RDS Archive / Documentation. You can download it as:
http://members.aol.com/Euphoria2/abgte2.zip (463K)
Regards,
Rob Craig
Rapid Deployment Software
http://members.aol.com/FilesEu/
11. Re: Dumb question by a beginner
Good news for the current pool of newbies, and future recruits also. I have
taken it upon myself (with a little support from David Gay) to write a
current and up to date version of "Euphoria for Newbies" (kinda like a
beginner's guide to Euphoria, but David wouldn't let me steal the name :}).
Expect a beta release in the next couple of weeks.
Adam Weeden
WeedenSoft Technologies
----- Original Message -----
From: Robert Craig <rds at ATTCANADA.NET>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Friday, May 14, 1999 12:15 AM
Subject: Re: Dumb question by a beginner
> Dan writes:
> >Greg Phillips writes:
> >> a great
> >>resource for questions like this is his 'A Beginners Guide to
> >>Euphoria'. It isn't availiable for download anymore, but it is an
> >>excellent tutorial that'll get you started in no time. Should you want
> >>it, email me, and I can send it to you. Keep in mind, however, that
> >>it's current to version 1.5, *not* version 2.1. Some newer features,
> >>including Win32 support weren't part of version 1.5, but all
> >> the basics are in there.
> >>
> >>Thank you,
> >>Greg Phillips
>
> >To Greg Phillips,
> > If you could email me a copy of the tutorial,
> > that would be great.
> > I too am a newby and am looking to learn how to program.
>
> David Gay's "Beginner's Guide to Euphoria" is in
> the RDS Archive / Documentation. You can download it as:
>
> http://members.aol.com/Euphoria2/abgte2.zip (463K)
>
> Regards,
> Rob Craig
> Rapid Deployment Software
> http://members.aol.com/FilesEu/
12. Re: Dumb question by a beginner
At 12:42 AM 5/14/99 -0400, you wrote:
>Good news for the current pool of newbies, and future recruits also. I have
>taken it upon myself (with a little support from David Gay) to write a
>current and up to date version of "Euphoria for Newbies" (kinda like a
>beginner's guide to Euphoria, but David wouldn't let me steal the name :}).
>Expect a beta release in the next couple of weeks.
>
>Adam Weeden
>WeedenSoft Technologies
If you could, could you include some suggestions of things to try and write ?
Thanks
"I'm not really sure if any of that made sense, but if I
go back
and try to sort it out I think I will start bleeding from
my ears."
13. Re: Dumb question by a beginner
Adam:
Why not call it Newbie's Guide to Euphoria ?
14. Re: Dumb question by a beginner
Cuz I was going toward Euphoria for Dummies, but didnt want to get sued.
Adam Weeden
----- Original Message -----
From: Bernie Ryan <bwryan at PCOM.NET>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Friday, May 14, 1999 9:57 AM
Subject: Re: Dumb question by a beginner
> Adam:
> Why not call it Newbie's Guide to Euphoria ?
15. Re: Dumb question by a beginner
At 11:08 AM 5/14/99 -0400, you wrote:
>Cuz I was going toward Euphoria for Dummies, but didnt want to get sued.
>
>Adam Weeden
Those "titles" never appealed to me... so I can't see them for Euphoria,
either.
"Euphoria for Dummies"
"Idiot's Guide to Euphoria"
"Euphoria for the Complete Moron"
"The Brainless <censored>'s Euphoria Instructional Video"
Something simple that doesn't insult the reader will do fine.
16. Re: Dumb question by a beginner
> Good news for the current pool of newbies, and future recruits also. I
have
> taken it upon myself (with a little support from David Gay) to write a
> current and up to date version of "Euphoria for Newbies" (kinda like a
> beginner's guide to Euphoria, but David wouldn't let me steal the name
:}).
> Expect a beta release in the next couple of weeks.
The offer is still there if you want some assistance, Adam. Let any of us
know if you need help coding it. I'm sure the newcomers will be thrilled
with it when you release it.
I hope the tutorial covers how to use Euphoria in a Windows environment.
That was something I could never do.
Thanks
David Gay
17. Re: Dumb question by a beginner
I'm not sure if it will, if anyhting it will show how to use the MUCH
simpler Win32Lib (or if its released by then Llama).
Adam Weeden
-----Original Message-----
From: David Gay <moggie at INTERLOG.COM>
To: EUPHORIA at LISTSERV.MUOHIO.EDU <EUPHORIA at LISTSERV.MUOHIO.EDU>
Date: Saturday, May 15, 1999 8:04 AM
Subject: Re: Dumb question by a beginner
>> Good news for the current pool of newbies, and future recruits also. I
>have
>> taken it upon myself (with a little support from David Gay) to write a
>> current and up to date version of "Euphoria for Newbies" (kinda like a
>> beginner's guide to Euphoria, but David wouldn't let me steal the name
>:}).
>> Expect a beta release in the next couple of weeks.
>
>The offer is still there if you want some assistance, Adam. Let any of us
>know if you need help coding it. I'm sure the newcomers will be thrilled
>with it when you release it.
>
>I hope the tutorial covers how to use Euphoria in a Windows environment.
>That was something I could never do.
>
>Thanks
>
>David Gay