1. Coming From QBasic
- Posted by Lynn Kilroy <leks_transportation at hotmail.com> Jan 14, 2006
- 562 views
- Last edited Jan 15, 2006
My biggest curiousity is how do I get it to use subs in Included files? I type the include file line. It accepts that fine. Then I try to get it to do the screen mode thing, and that it doesn't seem to do so well. Also, if it's a one-line sub, perhaps I can just plug the line in to my code without the rest of the sub? One line subs only make sense to me if they are a sub that's called often and by many different routines, and I want it to look purdy instead of using the languages default command synstax. An example from QBasic is my Inkey routine. It's call is purdy simple: > Inkey a -where a is the name of a string variable. I use Inkey as a subroutine because I think a = INKEY$ is purdy ugly, so I stuck the command in a subroutine so in my program, I need only a = INKEY$ once. The rest of the time, it's Inkey a. This demonstrates some of my confusion, actually, and from whence it stemms. Euphoria was defined as an easy language to use. Defined as even easier to use than QBasic, it seemed to imply. I figured then it should be pretty easy to begin playing with it. But there seems to be a few things it's conspicuously missing. In the instance above, a subroutine is defined by a DECLARE SUB statement, with variables to pass to it defined after. > DECLARE SUB Inkey (a AS STRING) The sub is delineated by SUB ... END SUB. > SUB Inkey (a AS STRING) > > a = INKEY$ > > END SUB The subroutine name then becomes a KEYWORD. > DIM a AS STRING > > WHILE a <> CHR$(27) > > Inkey a > > WEND This is pretty simple. Now how do I do this in Euphoria? Speaking of Screen Modes, one of my programs uses a Screen Mode about which I can find no information in Euphoria Documentation available to me. I use the QBASIC command > WIDTH 80, 50 to obtain this screen mode. It is a text only mode, 80 columns by 50 rows. I would use 80 x 60, but ... That's a graphical screen mode, called by the combination > SCREEN 12 > WIDTH 80, 60 and tends to be a bit slow. Not that it matters, it's a smaller program. As I've not gotten the program to do any of these things yet, I've note reached any of the other parts that I'm curious about. I have looked through the code, and wondered about things like PUT and GET for graphics. I have mine own versions of these, but they require special files that I have to be able to write a program to write. They work well with 16 colors, but more than that, they're pretty much useless, as they don't compress files too well with more than sixteen colors. I've some theories how to expand it's abilities, but really have no need to use them {my graphics tend to stop at 16 colors, usually fewer, if I use them at all}. Basically, what I'm looking for is something with the flexibility and ease of use of QBasic but for more modern programming environments. Euphoria looks like it might be able to fill the bill, but first, I have to understand the very basic differences between it and QB. I don't mean the technical stuff like variable groups and nests and stuff {all that's kind of neat, though, and part of my attraction to the language}, but the basic syntax and use of the language, and perhaps help in handling graphics with the simplicity of QB, but without all the buggery errors. Another thing ... I have a QB Compiler. From what I saw in the documentations, there is no Euphoria Compiler. This is something of a drawback to me. I can purchase a Euphoria binder program, I can even purchase a Euphoria to C translater. But no Euphoria direct to Executable Compiler. I imagine this is not a problem with Linux, but with Windows, it becomes a problem that is really quite large. From what I can see, there are no free c compilers for Windows. This means that no matter the cost of the binder and translator, the overall cost of Euphoria for the programmer is still prohibitively expensive. Sure, QB is old, and yes, it's very limited. But at least I can distribute my QBasic Programs in such a format that people don't have to download a QB interpreter to use them, or, worse, purchase a $500.00 program in order to compile it and use it. Nor do I have to risk the uncredited theft my source code {which I make available under GPL, but still, the compiled version preserves my status as original author on the original code}. Love & Friendship & Blessed Be! Lynn Erika Kilroy
2. Re: Coming From QBasic
- Posted by Jason Gade <jaygade at yahoo.com> Jan 14, 2006
- 519 views
- Last edited Jan 15, 2006
Lynn Kilroy wrote: > > My biggest curiousity is how do I get it to use subs in Included files? > I type the include file line. It accepts that fine. Then I try to get > it to do the screen mode thing, and that it doesn't seem to do so well. > Also, if it's a one-line sub, perhaps I can just plug the line in to my > code without the rest of the sub? One line subs only make sense to me > if they are a sub that's called often and by many different routines, > and I want it to look purdy instead of using the languages default > command synstax. An example from QBasic is my Inkey routine. It's call > is purdy simple: > > > Inkey a > > -where a is the name of a string variable. > > I use Inkey as a subroutine because I think a = INKEY$ is purdy ugly, so > I stuck the command in a subroutine so in my program, I need only a = > INKEY$ once. The rest of the time, it's Inkey a. > > This demonstrates some of my confusion, actually, and from whence it > stemms. Euphoria was defined as an easy language to use. Defined as > even easier to use than QBasic, it seemed to imply. I figured then it > should be pretty easy to begin playing with it. But there seems to be a > few things it's conspicuously missing. > > In the instance above, a subroutine is defined by a DECLARE SUB > statement, with variables to pass to it defined after. > > > DECLARE SUB Inkey (a AS STRING) > > The sub is delineated by SUB ... END SUB. > > > SUB Inkey (a AS STRING) > > > > a = INKEY$ > > > > END SUB > > The subroutine name then becomes a KEYWORD. > > > DIM a AS STRING > > > > WHILE a <> CHR$(27) > > > > Inkey a > > > > WEND > > This is pretty simple. Now how do I do this in Euphoria? This is very simple. But I really think you need to look at the Euphoria Reference Manual. It is included with your Euphoria download as well as being available on the RDS website at http://www.rapideuphoria.com/refman.htm and this file will answer most of your questions here, including the ones referring how to use graphics. Also look for A Beginner's Guide to Euphoria http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=abgte its kind of old (and I haven't looked at it in awhile) but I think that its pretty good. <snip graphics questions -- see reference manual> > Basically, what I'm looking for is something with the flexibility and > ease of use of QBasic but for more modern programming environments. > Euphoria looks like it might be able to fill the bill, but first, I have > to understand the very basic differences between it and QB. I don't > mean the technical stuff like variable groups and nests and stuff {all > that's kind of neat, though, and part of my attraction to the language}, > but the basic syntax and use of the language, and perhaps help in > handling graphics with the simplicity of QB, but without all the buggery > errors. > > Another thing ... I have a QB Compiler. From what I saw in the > documentations, there is no Euphoria Compiler. This is something of a > drawback to me. I can purchase a Euphoria binder program, I can even > purchase a Euphoria to C translater. But no Euphoria direct to > Executable Compiler. I imagine this is not a problem with Linux, but > with Windows, it becomes a problem that is really quite large. From > what I can see, there are no free c compilers for Windows. This means > that no matter the cost of the binder and translator, the overall cost > of Euphoria for the programmer is still prohibitively expensive. Sure, > QB is old, and yes, it's very limited. But at least I can distribute my > QBasic Programs in such a format that people don't have to download a QB > interpreter to use them, or, worse, purchase a $500.00 program in order > to compile it and use it. Nor do I have to risk the uncredited theft my > source code {which I make available under GPL, but still, the compiled > version preserves my status as original author on the original code}. > > Love & Friendship & Blessed Be! > Lynn Erika Kilroy > > The Euphoria to C translator comes with Euphoria. And yes, there are free C compilers for DOS/Windows. See http://www.rapideuphoria.com/e2c.htm for more info. But even if you don't bind or translate your programs, you can still distribute the interpreter with your program. It's not that big, about 244 KB for the DOS interpreter. Plus your include files. Shouldn't be a problem for smaller projects. Hope that helps. -- "Actually, I'm sitting on my butt staring at a computer screen." - Tom Tomorrow j.
3. Re: Coming From QBasic
- Posted by D. Newhall <derek_newhall at yahoo.com> Jan 14, 2006
- 535 views
- Last edited Jan 15, 2006
Lynn Kilroy wrote: > > My biggest curiousity is how do I get it to use subs in Included files? > I type the include file line. It accepts that fine. Then I try to get > it to do the screen mode thing, and that it doesn't seem to do so well. > Also, if it's a one-line sub, perhaps I can just plug the line in to my > code without the rest of the sub? One line subs only make sense to me > if they are a sub that's called often and by many different routines, > and I want it to look purdy instead of using the languages default > command synstax. An example from QBasic is my Inkey routine. It's call > is purdy simple: (snip) To move stuff between includes you need to declare it as global like so: global integer index global function do_stuff() ... end function it also has to be declared as such before you use it no matter which file it is in. However, there is no call-by-reference in Euphoria so certain things like the inkey example will not work (I think my QB is rusty). Stuff like "Input ans$" would be used in Euphoria as "ans = input()". There's also a QBasic to Euphoria translator in the Archive. http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=qbasic > Speaking of Screen Modes, one of my programs uses a Screen Mode about > which I can find no information in Euphoria Documentation available to > me. I use the QBASIC command (snip) Check the documnetation on graphics ans sound and the graphics.e include file. I think the routines you want are graphics_mode() and/or video_config(). > Basically, what I'm looking for is something with the flexibility and > ease of use of QBasic but for more modern programming environments. > Euphoria looks like it might be able to fill the bill, but first, I have > to understand the very basic differences between it and QB. I don't > mean the technical stuff like variable groups and nests and stuff {all > that's kind of neat, though, and part of my attraction to the language}, > but the basic syntax and use of the language, and perhaps help in > handling graphics with the simplicity of QB, but without all the buggery > errors. Euphoria is certainly a good replacement (I use in place of all the stuff I used QBasic for both professionally and privately). However, certain things aren't as easy but in the long run are more powerful and flexible (I think). Also, Euphoria is constantly improved and MUCH faster than QBasic (the Euphoria interpreter beats some compiled QBasic programs). > Another thing ... I have a QB Compiler. From what I saw in the > documentations, there is no Euphoria Compiler. This is something of a > drawback to me. I can purchase a Euphoria binder program, I can even > purchase a Euphoria to C translater. But no Euphoria direct to > Executable Compiler. I imagine this is not a problem with Linux, but > with Windows, it becomes a problem that is really quite large. From > what I can see, there are no free c compilers for Windows. This means > that no matter the cost of the binder and translator, the overall cost > of Euphoria for the programmer is still prohibitively expensive. Sure, > QB is old, and yes, it's very limited. But at least I can distribute my > QBasic Programs in such a format that people don't have to download a QB > interpreter to use them, or, worse, purchase a $500.00 program in order > to compile it and use it. Nor do I have to risk the uncredited theft my > source code {which I make available under GPL, but still, the compiled > version preserves my status as original author on the original code}. There is a free version of the C translator that has a notice saying it's unregistered that you could use. Also, there are free Windows C compilers. Open Watcom (http://www.openwatcom.org) is one which I highly recommend. The Euphoria Standard Library project : http://esl.sourceforge.net/ The Euphoria Standard Library mailing list : https://lists.sourceforge.net/lists/listinfo/esl-discussion
4. Re: Coming From QBasic
- Posted by don cole <doncole at pacbell.net> Jan 15, 2006
- 560 views
Lynn Kilroy wrote: > > My biggest curiousity is how do I get it to use subs in Included files? > I type the include file line. It accepts that fine. Then I try to get > it to do the screen mode thing, and that it doesn't seem to do so well. > Also, if it's a one-line sub, perhaps I can just plug the line in to my > code without the rest of the sub? One line subs only make sense to me > if they are a sub that's called often and by many different routines, > and I want it to look purdy instead of using the languages default > command synstax. An example from QBasic is my Inkey routine. It's call > is purdy simple: > > > Inkey a > > -where a is the name of a string variable. \ integer a a=wait_key() > > I use Inkey as a subroutine because I think a = INKEY$ is purdy ugly, so > I stuck the command in a subroutine so in my program, I need only a = > INKEY$ once. The rest of the time, it's Inkey a. --start of sub function get_keystroke()--I made this up it's not a Euphoria sub integer a while 1=1 do a=wait_key if a then return a end if end while end function --end of sub --start program-- integer b b=get_keystroke()-- your sub or function that you just wrote puts(1,b) b=wait_key()--stops program so you can read it --end program by the way -- is the same as rem > > This demonstrates some of my confusion, actually, and from whence it > stemms. Euphoria was defined as an easy language to use. Defined as > even easier to use than QBasic, it seemed to imply. I figured then it > should be pretty easy to begin playing with it. But there seems to be a > few things it's conspicuously missing. > > In the instance above, a subroutine is defined by a DECLARE SUB > statement, with variables to pass to it defined after. > > > DECLARE SUB Inkey (a AS STRING) > > The sub is delineated by SUB ... END SUB. > > > SUB Inkey (a AS STRING) > > > > a = INKEY$ > > > > END SUB > > The subroutine name then becomes a KEYWORD. > > > DIM a AS STRING > > > > WHILE a <> CHR$(27) > > > > Inkey a > > > > WEND > While 1=1 do a=wait_key() if a=27 then puts(1,"goodby") exit end if end while a=wait_key--just to stop so you can read 'goodby' > This is pretty simple. Now how do I do this in Euphoria? > > Speaking of Screen Modes, one of my programs uses a Screen Mode about > which I can find no information in Euphoria Documentation available to > me. I use the QBASIC command > > > WIDTH 80, 50 > > to obtain this screen mode. It is a text only mode, 80 columns by 50 > rows. I would use 80 x 60, but ... That's a graphical screen mode, > called by the combination > > > SCREEN 12 > > WIDTH 80, 60 > > and tends to be a bit slow. Not that it matters, it's a smaller > program. > > As I've not gotten the program to do any of these things yet, I've note > reached any of the other parts that I'm curious about. I have looked > through the code, and wondered about things like PUT and GET for > graphics. I have mine own versions of these, but they require special > files that I have to be able to write a program to write. They work > well with 16 colors, but more than that, they're pretty much useless, as > they don't compress files too well with more than sixteen colors. I've > some theories how to expand it's abilities, but really have no need to > use them {my graphics tend to stop at 16 colors, usually fewer, if I use > them at all}. > > Basically, what I'm looking for is something with the flexibility and > ease of use of QBasic but for more modern programming environments. > Euphoria looks like it might be able to fill the bill, but first, I have > to understand the very basic differences between it and QB. I don't > mean the technical stuff like variable groups and nests and stuff {all > that's kind of neat, though, and part of my attraction to the language}, > but the basic syntax and use of the language, and perhaps help in > handling graphics with the simplicity of QB, but without all the buggery > errors. > > Another thing ... I have a QB Compiler. From what I saw in the > documentations, there is no Euphoria Compiler. This is something of a > drawback to me. I can purchase a Euphoria binder program, I can even > purchase a Euphoria to C translater. But no Euphoria direct to > Executable Compiler. I imagine this is not a problem with Linux, but > with Windows, it becomes a problem that is really quite large. From > what I can see, there are no free c compilers for Windows. This means > that no matter the cost of the binder and translator, the overall cost > of Euphoria for the programmer is still prohibitively expensive. Sure, > QB is old, and yes, it's very limited. But at least I can distribute my > QBasic Programs in such a format that people don't have to download a QB > interpreter to use them, or, worse, purchase a $500.00 program in order > to compile it and use it. Nor do I have to risk the uncredited theft my > source code {which I make available under GPL, but still, the compiled > version preserves my status as original author on the original code}. > > Love & Friendship & Blessed Be! > Lynn Erika Kilroy > > Don Cole A Bug is an un-documented feature. A Feature is a documented Bug.
5. Re: Coming From QBasic
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Jan 15, 2006
- 524 views
<snip> >integer a >a=wait_key() or get_key, getc, gets. <snip> > a=wait_key missing (). Also not sure why this is wrapped in a loop. >a=wait_key--just to stop so you can read 'goodby' again, missing () Regards, Pete
6. Re: Coming From QBasic
- Posted by don cole <doncole at pacbell.net> Jan 15, 2006
- 564 views
Pete Lomax wrote: > > <snip> > >integer a > >a=wait_key() > or get_key, getc, gets. > <snip> > > a=wait_key > missing (). Also not sure why this is wrapped in a loop. > >a=wait_key--just to stop so you can read 'goodby' > again, missing () > > Regards, > Pete > > Yes Pete, you are right on all counts. Actually wait_key{} is not equivalent of Inkey. It should be something like this:
function inkey() sequence words integer a words="" while 1 do a=wait_key() if a=13 then return words end if words=words & sprintf("%s",a) end while end function --start program sequence input integer a input=inkey() puts(1,input) a=wait_key() --end program Actually I was thinking of writing a tutorial to convert Basic to Euphoria. example: global function VAL(sequence seq) --returns a decimal given a sequence atom de sequence value_string value_string=value(seq[1..length(seq)]) de = value_string[2] return de end function
But I never got around to it. Don Cole A Bug is an un-documented feature. A Feature is a documented Bug.
7. Re: Coming From QBasic
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 16, 2006
- 522 views
Does the Global function thingy have to be included in the main body of the= code, even if the function is in an included file? And how about the subroutines? How do I call them? Love & Friendship & Blessed Be! Lynn Erika Kilroy >From: "D. Newhall" <guest at RapidEuphoria.com> >Reply-To: EUforum at topica.com >To: EUforum at topica.com >Subject: Re: Coming From QBasic >Date: Sat, 14 Jan 2006 14:34:21 -0800 > > >posted by: D. Newhall <derek_newhall at yahoo.com> > >Lynn Kilroy wrote: > > > > My biggest curiousity is how do I get it to use subs in Included files?= > > I type the include file line. It accepts that fine. Then I try to get= > > it to do the screen mode thing, and that it doesn't seem to do so well.= > > Also, if it's a one-line sub, perhaps I can just plug the line in to my= > > code without the rest of the sub? One line subs only make sense to me > > if they are a sub that's called often and by many different routines, > > and I want it to look purdy instead of using the languages default > > command synstax. An example from QBasic is my Inkey routine. It's cal= l > > is purdy simple: >(snip) > >To move stuff between includes you need to declare it as global like so: > >global integer index > >global function do_stuff() > ... >end function > >it also has to be declared as such before you use it no matter which file= >it is in. > >However, there is no call-by-reference in Euphoria so certain things like= >the inkey example will not work (I think my QB is rusty). Stuff like "Inpu= t >ans$" would be used in Euphoria as "ans = input()". > >There's also a QBasic to Euphoria translator in the Archive. >=20=20 >http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=o= n&gen=on&keywords=qbasic > > > > Speaking of Screen Modes, one of my programs uses a Screen Mode about > > which I can find no information in Euphoria Documentation available to > > me. I use the QBASIC command >(snip) > >Check the documnetation on graphics ans sound and the graphics.e include= >file. I think the routines you want are graphics_mode() and/or >video_config(). > > > Basically, what I'm looking for is something with the flexibility and > > ease of use of QBasic but for more modern programming environments. > > Euphoria looks like it might be able to fill the bill, but first, I hav= e > > to understand the very basic differences between it and QB. I don't > > mean the technical stuff like variable groups and nests and stuff {all > > that's kind of neat, though, and part of my attraction to the language}= , > > but the basic syntax and use of the language, and perhaps help in > > handling graphics with the simplicity of QB, but without all the bugger= y > > errors. > >Euphoria is certainly a good replacement (I use in place of all the stuff = I >used QBasic for both professionally and privately). However, certain thing= s >aren't as easy but in the long run are more powerful and flexible (I >think). Also, Euphoria is constantly improved and MUCH faster than QBasic= >(the Euphoria interpreter beats some compiled QBasic programs). > > > > Another thing ... I have a QB Compiler. From what I saw in the > > documentations, there is no Euphoria Compiler. This is something of a > > drawback to me. I can purchase a Euphoria binder program, I can even > > purchase a Euphoria to C translater. But no Euphoria direct to > > Executable Compiler. I imagine this is not a problem with Linux, but > > with Windows, it becomes a problem that is really quite large. From > > what I can see, there are no free c compilers for Windows. This means > > that no matter the cost of the binder and translator, the overall cost > > of Euphoria for the programmer is still prohibitively expensive. Sure,= > > QB is old, and yes, it's very limited. But at least I can distribute m= y > > QBasic Programs in such a format that people don't have to download a Q= B > > interpreter to use them, or, worse, purchase a $500.00 program in order= > > to compile it and use it. Nor do I have to risk the uncredited theft m= y > > source code {which I make available under GPL, but still, the compiled > > version preserves my status as original author on the original code}. > >There is a free version of the C translator that has a notice saying it's= >unregistered that you could use. Also, there are free Windows C compilers.= >Open Watcom (http://www.openwatcom.org) is one which I highly recommend. > > >The Euphoria Standard Library project : > http://esl.sourceforge.net/ >The Euphoria Standard Library mailing list : > https://lists.sourceforge.net/lists/listinfo/esl-discussion > > > >
8. Re: Coming From QBasic
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 16, 2006
- 519 views
Correct me if I'm wrong, but wouldn't wait_key wait for a keypress? I use= Inkey$ because it doesn't wait. If there was no keypress since it's last= pass, it returns a null string. {Giggles} And how is a null string represented numerically? -1? {Laughs} Even if a=string:a=chr$(0), then = a>"",=20 or a is more than a Nul String! {Grins} Love & Friendship & Blessed Be! Lynn Erika Kilroy >From: Pete Lomax <petelomax at blueyonder.co.uk> >Reply-To: EUforum at topica.com >To: EUforum at topica.com >Subject: Re: Coming From QBasic >Date: Sun, 15 Jan 2006 13:25:12 +0000 > > ><snip> > >integer a > >a=wait_key() >or get_key, getc, gets. ><snip> > > a=wait_key >missing (). Also not sure why this is wrapped in a loop. > >a=wait_key--just to stop so you can read 'goodby' >again, missing () > >Regards, >Pete > > > > Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
9. Re: Coming From QBasic
- Posted by Chris Burch <chriscrylex at aol.com> Jan 16, 2006
- 532 views
hi integer c c = get_key() returns -1 if nothing pressed http://members.aol.com/chriscrylex/euphoria.htm http://uboard.proboards32.com/ http://members.aol.com/chriscrylex/EUSQLite/eusql.html
10. Re: Coming From QBasic
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 16, 2006
- 544 views
Would it be possible to rename these functions? I assume they're function,= by the way they're formatted. Also, could they perhaps be converted to subroutines? I tended to put QBasic Functions in subroutines because I preferred the Subroutine Format over the Function Format. Love & Friendship & Blessed Be! Lynn Erika Kilroy >From: Chris Burch <guest at RapidEuphoria.com> >Reply-To: EUforum at topica.com >To: EUforum at topica.com >Subject: Re: Coming From QBasic >Date: Mon, 16 Jan 2006 00:49:50 -0800 > > >posted by: Chris Burch <chriscrylex at aol.com> > > >hi > >integer c > >c = get_key() > >returns -1 if nothing pressed > > >http://members.aol.com/chriscrylex/euphoria.htm >http://uboard.proboards32.com/ >http://members.aol.com/chriscrylex/EUSQLite/eusql.html > > > >
11. Re: Coming From QBasic
- Posted by Chris Burch <chriscrylex at aol.com> Jan 16, 2006
- 537 views
Lynn Kilroy wrote: > > Would it be possible to rename these functions? I assume they're function,= > > by the way they're formatted. Also, could they perhaps be converted to > subroutines? I tended to put QBasic Functions in subroutines because I > preferred the Subroutine Format over the Function Format. > > Love & Friendship & Blessed Be! > Lynn Erika Kilroy > > > >From: Chris Burch <guest at RapidEuphoria.com> > >Reply-To: EUforum at topica.com > >To: EUforum at topica.com > >Subject: Re: Coming From QBasic > >Date: Mon, 16 Jan 2006 00:49:50 -0800 > > > > > >posted by: Chris Burch <chriscrylex at aol.com> > > > > > >hi > > > >integer c > > > >c = get_key() > > > >returns -1 if nothing pressed > > > > > ><a > >href="http://members.aol.com/chriscrylex/euphoria.htm">http://members.aol.com/chriscrylex/euphoria.htm</a> > ><a href="http://uboard.proboards32.com/">http://uboard.proboards32.com/</a> > ><a > >href="http://members.aol.com/chriscrylex/EUSQLite/eusql.html">http://members.aol.com/chriscrylex/EUSQLite/eusql.html</a> > > > > Hi Ah ha - the goto / gosub/return argument again. Short answer no - look through the mailing list archives for all the pro and con arguments. Assume there are no subroutines - in the qbasic sense. When you get used to euphoria, its far prettier and easier to read. As with most things euphoria, there are work arounds functions - return a value procedures - do not return a value both need to to be found in your program (in the way the program is read), before you actually call them (can use routine_ids, but keep it simple for now) The 'preferred' method is to only use local variables to your functions/procedured, as this leads to prettier, more re usable code, eg
function foo(integer x) integer y y = x * 2 return y end function integer z z = foo(2)
now if you used untidy global variables (bad programming practice (hands up those who NEVER do it))
integer y, z procedure foo(integer x) y = x * 2 end procedure foo(4) z = y
yeuch, horrible. Is this what you meant. Also say goodbye to on x gosub/goto, and switch/case statements (are these in qbasic?) Chris http://members.aol.com/chriscrylex/euphoria.htm http://uboard.proboards32.com/ http://members.aol.com/chriscrylex/EUSQLite/eusql.html
12. Re: Coming From QBasic
- Posted by don cole <doncole at pacbell.net> Jan 16, 2006
- 531 views
Lynn Kilroy wrote: > > Does the Global function thingy have to be included in the main body of the= > Not necessarly but it has to be declared before it is called. > code, even if the function is in an included file? And how about the > subroutines? How do I call them? > > Love & Friendship & Blessed Be! > Lynn Erika Kilroy Don Cole A Bug is an un-documented feature. A Feature is a documented Bug. > > > >From: "D. Newhall" <guest at RapidEuphoria.com> > >Reply-To: EUforum at topica.com > >To: EUforum at topica.com > >Subject: Re: Coming From QBasic > >Date: Sat, 14 Jan 2006 14:34:21 -0800 > > > > > >posted by: D. Newhall <derek_newhall at yahoo.com> > > > >Lynn Kilroy wrote: > > > > > > My biggest curiousity is how do I get it to use subs in Included files?= > > > > I type the include file line. It accepts that fine. Then I try to get= > > > > it to do the screen mode thing, and that it doesn't seem to do so well.= > > > > Also, if it's a one-line sub, perhaps I can just plug the line in to my= > > > > code without the rest of the sub? One line subs only make sense to me > > > if they are a sub that's called often and by many different routines, > > > and I want it to look purdy instead of using the languages default > > > command synstax. An example from QBasic is my Inkey routine. It's cal= > l > > > is purdy simple: > >(snip) > > > >To move stuff between includes you need to declare it as global like so: > > > >global integer index > > > >global function do_stuff() > > ... > >end function > > > >it also has to be declared as such before you use it no matter which file= > > >it is in. > > > >However, there is no call-by-reference in Euphoria so certain things like= > > >the inkey example will not work (I think my QB is rusty). Stuff like "Inpu= > t > >ans$" would be used in Euphoria as "ans = input()". > > > >There's also a QBasic to Euphoria translator in the Archive. > >=20=20 > ><a > >href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=o=">http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=o=</a> > n&gen=on&keywords=qbasic > > > > > > > Speaking of Screen Modes, one of my programs uses a Screen Mode about > > > which I can find no information in Euphoria Documentation available to > > > me. I use the QBASIC command > >(snip) > > > >Check the documnetation on graphics ans sound and the graphics.e include= > > >file. I think the routines you want are graphics_mode() and/or > >video_config(). > > > > > Basically, what I'm looking for is something with the flexibility and > > > ease of use of QBasic but for more modern programming environments. > > > Euphoria looks like it might be able to fill the bill, but first, I hav= > e > > > to understand the very basic differences between it and QB. I don't > > > mean the technical stuff like variable groups and nests and stuff {all > > > that's kind of neat, though, and part of my attraction to the language}= > , > > > but the basic syntax and use of the language, and perhaps help in > > > handling graphics with the simplicity of QB, but without all the bugger= > y > > > errors. > > > >Euphoria is certainly a good replacement (I use in place of all the stuff = > I > >used QBasic for both professionally and privately). However, certain thing= > s > >aren't as easy but in the long run are more powerful and flexible (I > >think). Also, Euphoria is constantly improved and MUCH faster than QBasic= > > >(the Euphoria interpreter beats some compiled QBasic programs). > > > > > > > Another thing ... I have a QB Compiler. From what I saw in the > > > documentations, there is no Euphoria Compiler. This is something of a > > > drawback to me. I can purchase a Euphoria binder program, I can even > > > purchase a Euphoria to C translater. But no Euphoria direct to > > > Executable Compiler. I imagine this is not a problem with Linux, but > > > with Windows, it becomes a problem that is really quite large. From > > > what I can see, there are no free c compilers for Windows. This means > > > that no matter the cost of the binder and translator, the overall cost > > > of Euphoria for the programmer is still prohibitively expensive. Sure,= > > > > QB is old, and yes, it's very limited. But at least I can distribute m= > y > > > QBasic Programs in such a format that people don't have to download a Q= > B > > > interpreter to use them, or, worse, purchase a $500.00 program in order= > > > > to compile it and use it. Nor do I have to risk the uncredited theft m= > y > > > source code {which I make available under GPL, but still, the compiled > > > version preserves my status as original author on the original code}. > > > >There is a free version of the C translator that has a notice saying it's= > > >unregistered that you could use. Also, there are free Windows C compilers.= > > >Open Watcom (<a > >href="http://www.openwatcom.org">http://www.openwatcom.org</a>) is one which I > >highly recommend. > > > > > >The Euphoria Standard Library project : > > <a href="http://esl.sourceforge.net/">http://esl.sourceforge.net/</a> > >The Euphoria Standard Library mailing list : > > <a > > href="https://lists.sourceforge.net/lists/listinfo/esl-discussion">https://lists.sourceforge.net/lists/listinfo/esl-discussion</a> > > > > <snip>
13. Re: Coming From QBasic
- Posted by D. Newhall <derek_newhall at yahoo.com> Jan 16, 2006
- 530 views
Lynn Kilroy wrote: > > Does the Global function thingy have to be included in the main body of the= > code, even if the function is in an included file? And how about the > subroutines? How do I call them? > > Love & Friendship & Blessed Be! > Lynn Erika Kilroy (snip) As you've probably seen Euphoria doesn't have BASIC/COBOL style subroutines. However, you can kind of replicate this with procedures using global variables. integer key procedure inkey() key = get_key() end procedure inkey() When you declare something as global in an include file that means that when you include it everything declared as global becomes available in the main file. For example: -- Inside some include file constant BLAH = "stuff" global integer foo global function bar() ... end function procedure baz() ... end procedure When this file is included foo and bar can be used in the code whereas baz and blah can not. The Euphoria Standard Library project : http://esl.sourceforge.net/ The Euphoria Standard Library mailing list : https://lists.sourceforge.net/lists/listinfo/esl-discussion
14. Re: Coming From QBasic
- Posted by don cole <doncole at pacbell.net> Jan 16, 2006
- 533 views
Lynn Kilroy wrote: > > Would it be possible to rename these functions? I assume they're function,= > Yes as long as they haven't been declared in the standard Euphoria functions. Don't worry if they have you will get a namesake error. Hello Lynn, As Chris says the closest thing to subrounts in Euphoria are functions and procedures. Actually procedure is the same as subroute. And function is the same as procedure except that it returns something. Forget about goto.
procedure print_my_name() puts(1,"Lynn") end procedure function get_name_length(sequence name) retiurn length(name) end function ----program integer a print_my_name() printf(1,"my name is %d letters long",get_name_length("Lynn"))
You may notice that Euphoria comes with many standard include files such as get.e. You may write your own function and procedure and put them in your own include file. --file myget.e You could put the above function and procedure in that file, And put file in with the standard includes. From then on to use them in your program just put at the begining of your program. include myget.e I hope this is helpful. I know I switch to Euphoria from Liberty Basic so long ago I forgot what Inkey$ is exactlly. I switch mostly because of speed. Don Cole A Bug is an un-documented feature. A Feature is a documented Bug.
15. Re: Coming From QBasic
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 17, 2006
- 545 views
How would I know something was declared at the right time in the include= file? I've looked in those files, and the subroutines, AKA procedures, wer= e in apparently random order. What's more, the code doesn't look as neat as= it could to me. Mebbe I'm just a finiky coder. For example, in my Graphics.E file, there appears to me some variable definitions {a def type= statement, I think} near the bottom of the file. Is this a normal procedure? Or is it a sign that the file is corrupted? Love & Friendship & Blessed Be! Lynn Erika Kilroy >From: don cole <guest at RapidEuphoria.com> >Reply-To: EUforum at topica.com >To: EUforum at topica.com >Subject: Re: Coming From QBasic >Date: Mon, 16 Jan 2006 08:59:16 -0800 > > >posted by: don cole <doncole at pacbell.net> > >Lynn Kilroy wrote: > > > > Does the Global function thingy have to be included in the main body of= >the= > > > >Not necessarly but it has to be declared before it is called. > > > code, even if the function is in an included file? And how about the > > subroutines? How do I call them? > > > > Love & Friendship & Blessed Be! > > Lynn Erika Kilroy > >Don Cole > > > > > > >From: "D. Newhall" <guest at RapidEuphoria.com> > > >Reply-To: EUforum at topica.com > > >To: EUforum at topica.com > > >Subject: Re: Coming From QBasic > > >Date: Sat, 14 Jan 2006 14:34:21 -0800 > > > > > > > > >posted by: D. Newhall <derek_newhall at yahoo.com> > > > > > >Lynn Kilroy wrote: > > > > > > > > My biggest curiousity is how do I get it to use subs in Included= >files?= > > > > > > I type the include file line. It accepts that fine. Then I try to= >get= > > > > > > it to do the screen mode thing, and that it doesn't seem to do so= >well.= > > > > > > Also, if it's a one-line sub, perhaps I can just plug the line in t= o >my= > > > > > > code without the rest of the sub? One line subs only make sense to= >me > > > > if they are a sub that's called often and by many different >routines, > > > > and I want it to look purdy instead of using the languages default > > > > command synstax. An example from QBasic is my Inkey routine. It's= >cal= > > l > > > > is purdy simple: > > >(snip) > > > > > >To move stuff between includes you need to declare it as global like= >so: > > > > > >global integer index > > > > > >global function do_stuff() > > > ... > > >end function > > > > > >it also has to be declared as such before you use it no matter which= >file= > > > > >it is in. > > > > > >However, there is no call-by-reference in Euphoria so certain things= >like= > > > > >the inkey example will not work (I think my QB is rusty). Stuff like= >"Inpu= > > t > > >ans$" would be used in Euphoria as "ans = input()". > > > > > >There's also a QBasic to Euphoria translator in the Archive. > > >=20=20 > > ><a=20 >href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on= &lnx=o=">http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win= =on&lnx=o=</a> > > n&gen=on&keywords=qbasic > > > > > > > > > > Speaking of Screen Modes, one of my programs uses a Screen Mode >about > > > > which I can find no information in Euphoria Documentation available= >to > > > > me. I use the QBASIC command > > >(snip) > > > > > >Check the documnetation on graphics ans sound and the graphics.e >include= > > > > >file. I think the routines you want are graphics_mode() and/or > > >video_config(). > > > > > > > Basically, what I'm looking for is something with the flexibility= >and > > > > ease of use of QBasic but for more modern programming environments.= > > > > Euphoria looks like it might be able to fill the bill, but first, I= >hav= > > e > > > > to understand the very basic differences between it and QB. I don'= t > > > > mean the technical stuff like variable groups and nests and stuff= >{all > > > > that's kind of neat, though, and part of my attraction to the >language}= > > , > > > > but the basic syntax and use of the language, and perhaps help in > > > > handling graphics with the simplicity of QB, but without all the= >bugger= > > y > > > > errors. > > > > > >Euphoria is certainly a good replacement (I use in place of all the= >stuff = > > I > > >used QBasic for both professionally and privately). However, certain= >thing= > > s > > >aren't as easy but in the long run are more powerful and flexible (I > > >think). Also, Euphoria is constantly improved and MUCH faster than >QBasic= > > > > >(the Euphoria interpreter beats some compiled QBasic programs). > > > > > > > > > > Another thing ... I have a QB Compiler. From what I saw in the > > > > documentations, there is no Euphoria Compiler. This is something o= f >a > > > > drawback to me. I can purchase a Euphoria binder program, I can= >even > > > > purchase a Euphoria to C translater. But no Euphoria direct to > > > > Executable Compiler. I imagine this is not a problem with Linux,= >but > > > > with Windows, it becomes a problem that is really quite large. Fro= m > > > > what I can see, there are no free c compilers for Windows. This= >means > > > > that no matter the cost of the binder and translator, the overall= >cost > > > > of Euphoria for the programmer is still prohibitively expensive.= =20=20 >Sure,= > > > > > > QB is old, and yes, it's very limited. But at least I can >distribute m= > > y > > > > QBasic Programs in such a format that people don't have to download= >a Q= > > B > > > > interpreter to use them, or, worse, purchase a $500.00 program in= >order= > > > > > > to compile it and use it. Nor do I have to risk the uncredited >theft m= > > y > > > > source code {which I make available under GPL, but still, the >compiled > > > > version preserves my status as original author on the original >code}. > > > > > >There is a free version of the C translator that has a notice saying= >it's= > > > > >unregistered that you could use. Also, there are free Windows C >compilers.= > > > > >Open Watcom (<a=20 >href="http://www.openwatcom.org">http://www.openwatcom.org</a>) is one= >which I highly recommend. > > > > > > > > >The Euphoria Standard Library project : > > > <a=20 >href="http://esl.sourceforge.net/">http://esl.sourceforge.net/</a> > > >The Euphoria Standard Library mailing list : > > > <a=20 >href="https://lists.sourceforge.net/lists/listinfo/esl-discussion">https= ://lists.sourceforge.net/lists/listinfo/esl-discussion</a> > > > > > > ><snip> > > > > Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
16. Re: Coming From QBasic
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 17, 2006
- 544 views
I see nothing wrong with passing an argument to a subroutine/procedure {to me, these are really the same thing}, and allowing that subroutine to alter it. In QBasic, if I said: >DECLARE SUB Inke (a AS STRING) > >SUB Inkey (a AS STRING) >a = INKEY$ >END SUB what I'm saying is Inkey requires the argument 'a,' which passes data to and can also extract data from the subroutine. If I included a local variable in that subroutine: >DECLARE SUB Inke (a AS STRING) > >SUB Inkey (a AS STRING) > >DIM Variable AS DOUBLE > >Variable = RND > >a = INKEY$ > >END SUB then Variable is only remembered by Inkey. but is never seen by the rest of the program. In this case, it is a useless excercise becuase nothing is done with it. As you say, local versus global. Also, in both cases above, the line >SUB Inkey (a AS STRING) means you *MUST* pass it an argument. That argument can be either a variable pointer or a constant hard coded as an argument. In the case of Inkey, you could pass it arguments the following way, and they would all work. >DIM KeyPress AS STRING > >Inkey KeyPress -Or- >Inkey X$ -Or- >Inkey " " The first two are variables. I never use the signed variables. Poor form, and rather tasteless to me, anymore, so the middle one is out. But I use variations of the top and bottom lines quite frequently, although in the case of Inkey, calling Inkey with " " as the argument {a hard coded constant} rather defeats the purpose. In Euphoria, the sub would look different. I'm going to use your code and take a whack at it. >Procedure Inkey(Integer Key) > Key = get_key() >End Procedure > >Integer Key > >Inkey(Key) Would this work? If not this precisely, then how would it be coded, precisely? The difference isn't so much that I use a global variable for it {Blech!} but that I pass a variable to it, and the variable is altered by the Subroutine/Procedure and then passed back to the main program {if the main program had a variable pointer in the first place}. Love & Friendship & Blessed Be! Lynn Erika Kilroy >From: "D. Newhall" <guest at RapidEuphoria.com> >Reply-To: EUforum at topica.com >To: EUforum at topica.com >Subject: Re: Coming From QBasic >Date: Mon, 16 Jan 2006 09:16:46 -0800 > > >posted by: D. Newhall <derek_newhall at yahoo.com> > >Lynn Kilroy wrote: > > > > Does the Global function thingy have to be included in the main body of >the= > > code, even if the function is in an included file? And how about the > > subroutines? How do I call them? > > > > Love & Friendship & Blessed Be! > > Lynn Erika Kilroy >(snip) > >As you've probably seen Euphoria doesn't have BASIC/COBOL style >subroutines. However, you can kind of replicate this with procedures using >global variables. > >integer key > >procedure inkey() > key = get_key() >end procedure > >inkey() > > >When you declare something as global in an include file that means that >when you include it everything declared as global becomes available in the >main file. For example: > >-- Inside some include file >constant BLAH = "stuff" > >global integer foo > >global function bar() > ... >end function > >procedure baz() > ... >end procedure > > >When this file is included foo and bar can be used in the code whereas baz >and blah can not. > > >The Euphoria Standard Library project : > http://esl.sourceforge.net/ >The Euphoria Standard Library mailing list : > https://lists.sourceforge.net/lists/listinfo/esl-discussion > > > >
17. Re: Coming From QBasic
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Jan 17, 2006
- 530 views
Lynn Kilroy wrote: > > How would I know something was declared at the right time in the include > file? I've looked in those files, and the subroutines, AKA procedures, > were in apparently random order. What's more, the code doesn't look as > neat as it could to me. Mebbe I'm just a finiky coder. For example, > in my Graphics.E file, there appears to me some variable definitions > {a def type statement, I think} near the bottom of the file. Is this > a normal procedure? Or is it a sign that the file is corrupted? Rob often has an inconsistent (and, IMHO, messy) coding style, but graphics.e seems pretty straightforward to me. I'm not sure what you mean by 'random order.' In Euphoria, you need to declare a routine or variable before you use it. From looking at the code, it looks like Rob wanted to put all the sound related things near each other. Why you'd want to have sound things in a file called graphics.e is another issue (I suspect that since this is a DOS-only function, it made sense to put it in the only DOS-only standard include file). Matt Lewis
18. Re: Coming From QBasic
- Posted by Jason Gade <jaygade at yahoo.com> Jan 17, 2006
- 524 views
Lynn Kilroy wrote: > > How would I know something was declared at the right time in the include= > > file? If it is declared before it is used. > I've looked in those files, and the subroutines, AKA procedures, wer= > e > in apparently random order. What's more, the code doesn't look as neat as= > > it could to me. Mebbe I'm just a finiky coder. For example, in my > Graphics.E file, there appears to me some variable definitions {a def type= > > statement, I think} near the bottom of the file. Is this a normal > procedure? Or is it a sign that the file is corrupted? Looking at my copy of graphics.e I see the following:
type frequency(integer x) return x >= 0 end type global procedure sound(frequency f) -- turn on speaker at frequency f -- turn off speaker if f is 0 machine_proc(M_SOUND, f) end procedure
What this is doing is defining a type called frequency. This is a function that returns a value. Because it is defined as a 'type', the interpreter also calls it to validate a value declared as a 'frequency'. What it does is to ensure that its input is greater than zero. If it is, it returns true or one (same thing in Euphoria). Else it returns false or zero. If you make a call z = frequency(x) then it checks if x is greater than zero and sets z to one or zero accordingly. However it you do this: frequency f -- declare variable f to be a frequency f = -100 -- program will fail with a typecheck error It is supposed to help you debug or catch errors in your program. 'frequency' is declared where it is because it is only used by the 'sound' procedure immediately following it. Since frequency is not declared as 'global' it cannot be used outside of graphics.e. But since sound *is* declared as global it will be visible to any file that has the statement include graphics.e in it. Make sense? -- Have you tried running the examples? Can you tell us what kind of error you are getting? I understand you are comparing Euphoria to QBasic and trying to match up what you know in order to learn what Euphoria provides. But I don't understand your problems exactly. Not trying to be unfriendly! -- "Actually, I'm sitting on my butt staring at a computer screen." - Tom Tomorrow j.
19. Re: Coming From QBasic
- Posted by Jason Gade <jaygade at yahoo.com> Jan 17, 2006
- 521 views
Lynn Kilroy wrote: > > I see nothing wrong with passing an argument to a subroutine/procedure {to > me, these are really the same thing}, and allowing that subroutine to alter > > it. In QBasic, if I said: > > >DECLARE SUB Inke (a AS STRING) > > > >SUB Inkey (a AS STRING) > >a = INKEY$ > >END SUB > > what I'm saying is Inkey requires the argument 'a,' which passes data to and > > can also extract data from the subroutine. If I included a local variable > > in that subroutine: > > >DECLARE SUB Inke (a AS STRING) > > > >SUB Inkey (a AS STRING) > > > >DIM Variable AS DOUBLE > > > >Variable = RND > > > >a = INKEY$ > > > >END SUB > > then Variable is only remembered by Inkey. but is never seen by the rest of > > the program. In this case, it is a useless excercise becuase nothing is > done with it. As you say, local versus global. > > Also, in both cases above, the line > > >SUB Inkey (a AS STRING) > > means you *MUST* pass it an argument. That argument can be either a > variable pointer or a constant hard coded as an argument. In the case of > Inkey, you could pass it arguments the following way, and they would all > work. > > >DIM KeyPress AS STRING > > > >Inkey KeyPress > > -Or- > > >Inkey X$ > > -Or- > > >Inkey " " > > The first two are variables. I never use the signed variables. Poor form, > > and rather tasteless to me, anymore, so the middle one is out. But I use > variations of the top and bottom lines quite frequently, although in the > case of Inkey, calling Inkey with " " as the argument {a hard coded > constant} rather defeats the purpose. > > In Euphoria, the sub would look different. I'm going to use your code and > take a whack at it. > > >Procedure Inkey(Integer Key) > > Key = get_key() > >End Procedure > > > >Integer Key > > > >Inkey(Key) > > Would this work? If not this precisely, then how would it be coded, > precisely? The difference isn't so much that I use a global variable for it > > {Blech!} but that I pass a variable to it, and the variable is altered by > the Subroutine/Procedure and then passed back to the main program {if the > main program had a variable pointer in the first place}. > > Love & Friendship & Blessed Be! > Lynn Erika Kilroy No, this wouldn't work because Euphoria doesn't use pointers and doesn't allow you to modify a variable passed in as an argument. Euphoria is case-sensitive, too, so "Integer" would not work in place of "integer". Unless you defined "Integer" seperately. -- "Actually, I'm sitting on my butt staring at a computer screen." - Tom Tomorrow j.
20. Re: Coming From QBasic
- Posted by don cole <doncole at pacbell.net> Jan 17, 2006
- 528 views
Lynn Kilroy wrote: > > How would I know something was declared at the right time in the include= > > file? <snip> You would get an error message saying DAH-DAH has not been declared. Don Cole A Bug is an un-documented feature. A Feature is a documented Bug.
21. Re: Coming From QBasic
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 17, 2006
- 533 views
The Inkey routine was an example of a subroutine I use a lot. It's pretty= basic, so it was a suitable example. And I never use GOTO, GOSUB, nor RETURN. I use DECLARE SUB, SUB ... END SUB. It looks exactly like your= Procedure thingy, except it uses the word SUB. I can't remember what that= other language called them. But it's all the same. The problem I've been running in to is rather simple. I say 'Include Graphics.E' It says 'Okay.' I say 'Graphics_Mode(260)' It says something= about Graphics_Mode {a subroutine graphics.e} is not defined or something t= o that affect. The include statement as first. Include always comes first.= =20=20 Oddly, I don't like it in QB, because I tend to like dabbling with my subroutines. {Blushes} There also seems to be these kinds of little quirks= that I run in to, too. {Blushes more} Love & Friendship & Blessed Be! Lynn Erika Kilroy >From: don cole <guest at RapidEuphoria.com> >Reply-To: EUforum at topica.com >To: EUforum at topica.com >Subject: Re: Coming From QBasic >Date: Mon, 16 Jan 2006 10:03:05 -0800 > > >posted by: don cole <doncole at pacbell.net> > >Lynn Kilroy wrote: > > > > Would it be possible to rename these functions? I assume they're >function,= > > > > Yes as long as they haven't been declared in the standard Euphoria >functions. > Don't worry if they have you will get a namesake error. > > >Hello Lynn, > >As Chris says the closest thing to subrounts in Euphoria >are functions and procedures. > >Actually procedure is the same as subroute. > >And function is the same as procedure except that it returns something. >Forget about goto. > >}}} <eucode> >procedure print_my_name() >puts(1,"Lynn") >end procedure > >function get_name_length(sequence name) > retiurn length(name) >end function > >----program >integer a >print_my_name() >printf(1,"my name is %d letters long",get_name_length("Lynn")) > ></eucode> {{{ > >You may notice that Euphoria comes with many standard include files such a= s >get.e. >You may write your own function and procedure and put them in your own >include >file. > >--file myget.e > You could put the above function and procedure in that file, > And put file in with the standard includes. > From then on to use them in your program just put at the begining of you= r >program. >include myget.e > >I hope this is helpful. >I know I switch to Euphoria from Liberty Basic so long ago I forgot what >Inkey$ is exactlly. > >I switch mostly because of speed. > >Don Cole > > > >
22. Re: Coming From QBasic
- Posted by Jeremy Peterson <ptl99 at hotmail.com> Jan 17, 2006
- 515 views
Hey Lynn. You have to write graphics_mode. Its lowercase and Eu is case sensitive. Jeremy Edmund Burke: "All that is necessary for evil to triumph is for good men to do nothing."
23. Re: Coming From QBasic
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 17, 2006
- 534 views
cc.ex:3 Graphics_Mode has not been declared Graphics_Mode (260) ^ ============================================================= include ..\..\Include\graphics.e Graphics_Mode (260) print (1, 768 / 8) ============================================================= -- Euphoria 2.5 -- Graphics & Sound Routines -- GRAPHICS MODES -- argument to graphics_mode() -- mode description -- ---- ----------- -- -1 restore to original default mode -- 0 40 x 25 text, 16 grey -- 1 40 x 25 text, 16/8 color -- 2 80 x 25 text, 16 grey -- 3 80 x 25 text, 16/8 color -- 4 320 x 200, 4 color -- 5 320 x 200, 4 grey -- 6 640 x 200, BW -- 7 80 x 25 text, BW -- 11 720 x 350, BW (many video cards are lacking this one) -- 13 320 x 200, 16 color -- 14 640 x 200, 16 color -- 15 640 x 350, BW (may be 4-color with blinking) -- 16 640 x 350, 4 or 16 color -- 17 640 x 480, BW -- 18 640 x 480, 16 color -- 19 320 x 200, 256 color -- 256 640 x 400, 256 color (some cards are missing this one) -- 257 640 x 480, 256 color (some cards are missing this one) -- 258 800 x 600, 16 color -- 259 800 x 600, 256 color -- 260 1024 x 768, 16 color -- 261 1024 x 768, 256 color -- COLOR values -- for characters and pixels global constant BLACK = 0, -- in graphics modes this is "transparent" GREEN = 2, MAGENTA = 5, WHITE = 7, GRAY = 8, BRIGHT_GREEN = 10, BRIGHT_MAGENTA = 13, BRIGHT_WHITE = 15 global integer BLUE, CYAN, RED, BROWN, BRIGHT_BLUE, BRIGHT_CYAN, BRIGHT_RED, YELLOW ============================================================= I'm trying to port a simple program. The program's simplicity {I thought} would allow me to get a feel for the language. But it's not working out. To me, this information is somewhat ambiguous. It's ambiguous becuase it appears clear, yet something's not working. Could it be the file cc.ex needs something more? Could it be the call to the subroutine isn't correct? I don't know. I really don't. Love & Friendship & Blessed Be! Lynn Erika Kilroy >From: Jason Gade <guest at RapidEuphoria.com> >Reply-To: EUforum at topica.com >To: EUforum at topica.com >Subject: Re: Coming From QBasic >Date: Tue, 17 Jan 2006 08:57:41 -0800 > > >posted by: Jason Gade <jaygade at yahoo.com> > >Lynn Kilroy wrote: > > > > How would I know something was declared at the right time in the >include= > > > > file? > >If it is declared before it is used. > > > I've looked in those files, and the subroutines, AKA procedures, wer= > > e > > in apparently random order. What's more, the code doesn't look as neat >as= > > > > it could to me. Mebbe I'm just a finiky coder. For example, in my > > Graphics.E file, there appears to me some variable definitions {a def >type= > > > > statement, I think} near the bottom of the file. Is this a normal > > procedure? Or is it a sign that the file is corrupted? > >Looking at my copy of graphics.e I see the following: > >}}} <eucode> >type frequency(integer x) > return x >= 0 >end type > >global procedure sound(frequency f) >-- turn on speaker at frequency f >-- turn off speaker if f is 0 > machine_proc(M_SOUND, f) >end procedure ></eucode> {{{ > >What this is doing is defining a type called frequency. This is a function >that returns a value. Because it is defined as a 'type', the interpreter >also calls it to validate a value declared as a 'frequency'. What it does >is to ensure that its input is greater than zero. If it is, it returns true >or one (same thing in Euphoria). Else it returns false or zero. > >If you make a call >z = frequency(x) >then it checks if x is greater than zero and sets z to one or zero >accordingly. > >However it you do this: >frequency f -- declare variable f to be a frequency >f = -100 -- program will fail with a typecheck error > >It is supposed to help you debug or catch errors in your program. > >'frequency' is declared where it is because it is only used by the 'sound' >procedure immediately following it. Since frequency is not declared as >'global' it cannot be used outside of graphics.e. But since sound *is* >declared as global it will be visible to any file that has the statement >include graphics.e >in it. > >Make sense? > >-- > >Have you tried running the examples? Can you tell us what kind of error you >are getting? > >I understand you are comparing Euphoria to QBasic and trying to match up >what you know in order to learn what Euphoria provides. But I don't >understand your problems exactly. > >Not trying to be unfriendly! > >-- >"Actually, I'm sitting on my butt staring at a computer screen." > - Tom Tomorrow > >j. > > > >
24. Re: Coming From QBasic
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 17, 2006
- 539 views
It's case sensative? {Looks throught the docs} I don't think I saw that mentioned anywhere. >From: Jason Gade <guest at RapidEuphoria.com> >Reply-To: EUforum at topica.com >To: EUforum at topica.com >Subject: Re: Coming From QBasic >Date: Tue, 17 Jan 2006 09:23:10 -0800 > > >posted by: Jason Gade <jaygade at yahoo.com> > >Lynn Kilroy wrote: > > > > I see nothing wrong with passing an argument to a subroutine/procedure= >{to > > me, these are really the same thing}, and allowing that subroutine to= >alter > > > > it. In QBasic, if I said: > > > > >DECLARE SUB Inke (a AS STRING) > > > > > >SUB Inkey (a AS STRING) > > >a = INKEY$ > > >END SUB > > > > what I'm saying is Inkey requires the argument 'a,' which passes data t= o >and > > > > can also extract data from the subroutine. If I included a local >variable > > > > in that subroutine: > > > > >DECLARE SUB Inke (a AS STRING) > > > > > >SUB Inkey (a AS STRING) > > > > > >DIM Variable AS DOUBLE > > > > > >Variable = RND > > > > > >a = INKEY$ > > > > > >END SUB > > > > then Variable is only remembered by Inkey. but is never seen by the res= t >of > > > > the program. In this case, it is a useless excercise becuase nothing i= s > > done with it. As you say, local versus global. > > > > Also, in both cases above, the line > > > > >SUB Inkey (a AS STRING) > > > > means you *MUST* pass it an argument. That argument can be either a > > variable pointer or a constant hard coded as an argument. In the case= >of > > Inkey, you could pass it arguments the following way, and they would al= l > > work. > > > > >DIM KeyPress AS STRING > > > > > >Inkey KeyPress > > > > -Or- > > > > >Inkey X$ > > > > -Or- > > > > >Inkey " " > > > > The first two are variables. I never use the signed variables. Poor= >form, > > > > and rather tasteless to me, anymore, so the middle one is out. But I= >use > > variations of the top and bottom lines quite frequently, although in th= e > > case of Inkey, calling Inkey with " " as the argument {a hard coded > > constant} rather defeats the purpose. > > > > In Euphoria, the sub would look different. I'm going to use your code= >and > > take a whack at it. > > > > >Procedure Inkey(Integer Key) > > > Key = get_key() > > >End Procedure > > > > > >Integer Key > > > > > >Inkey(Key) > > > > Would this work? If not this precisely, then how would it be coded, > > precisely? The difference isn't so much that I use a global variable= >for it > > > > {Blech!} but that I pass a variable to it, and the variable is altered= >by > > the Subroutine/Procedure and then passed back to the main program {if= >the > > main program had a variable pointer in the first place}. > > > > Love & Friendship & Blessed Be! > > Lynn Erika Kilroy > >No, this wouldn't work because Euphoria doesn't use pointers and doesn't= >allow you to modify a variable passed in as an argument. > >Euphoria is case-sensitive, too, so "Integer" would not work in place of= >"integer". Unless you defined "Integer" seperately. > >-- >"Actually, I'm sitting on my butt staring at a computer screen." > - Tom Tomorrow > >j. > > > >
25. Re: Coming From QBasic
- Posted by Jason Gade <jaygade at yahoo.com> Jan 17, 2006
- 535 views
Lynn Kilroy wrote: > > cc.ex:3 > Graphics_Mode has not been declared > Graphics_Mode (260) > ^ > ============================================================= > > include ..\..\Include\graphics.e > > Graphics_Mode (260) > > print (1, 768 / 8) > > ============================================================= Euphoria is case sensitive. Graphics_Mode(260) is not the same as graphics_mode(260). Try this:
include graphics.e -- needed for graphics_mode() include get.e -- needed for wait_key() integer old_gr -- a place to store the old graphics mode integer key -- a place to store a keypress old_gr = graphics_mode(260) -- note, this is a function, not a procedure print(1, 768 / 8) key = wait_key() -- wait until any key is pressed old_gr = graphics_mode(-1) -- return to default graphics mode
I've tested this and it works under Windows XP pro. It's DOS, of course, but it still works if run by ex.exe. Does that clear anything up? -- "Actually, I'm sitting on my butt staring at a computer screen." - Tom Tomorrow j.
26. Re: Coming From QBasic
- Posted by Craig Welch <craig at singmail.com> Jan 18, 2006
- 527 views
Lynn Kilroy wrote: > It's case sensative? {Looks throught the docs} I don't think I saw that > mentioned anywhere. {Craig looks through docs} 2.4.1 Identifiers ----------------- Identifiers, which consist of variable names and other user-defined symbols, may be of any length. Upper and lower *case* are distinct.
27. Re: Coming From QBasic
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 18, 2006
- 513 views
Thank you! Love & Friendship & Blessed Be! Lynn Erika Kilroy >From: Jason Gade <guest at RapidEuphoria.com> >Reply-To: EUforum at topica.com >To: EUforum at topica.com >Subject: Re: Coming From QBasic >Date: Tue, 17 Jan 2006 11:30:15 -0800 > > >posted by: Jason Gade <jaygade at yahoo.com> > >Lynn Kilroy wrote: > > > > cc.ex:3 > > Graphics_Mode has not been declared > > Graphics_Mode (260) > > ^ > > ======================== ========================= ============== > > > > include ..\..\Include\graphics.e > > > > Graphics_Mode (260) > > > > print (1, 768 / 8) > > > > ======================== ========================= ============== > >Euphoria is case sensitive. Graphics_Mode(260) is not the same as >graphics_mode(260). > >Try this: >}}} <eucode> >include graphics.e -- needed for graphics_mode() >include get.e -- needed for wait_key() > >integer old_gr -- a place to store the old graphics mode >integer key -- a place to store a keypress > >old_gr = graphics_mode(260) -- note, this is a function, not a procedure= >print(1, 768 / 8) > >key = wait_key() -- wait until any key is pressed >old_gr = graphics_mode(-1) -- return to default graphics mode ></eucode> {{{ > >I've tested this and it works under Windows XP pro. It's DOS, of course,= >but it still works if run by ex.exe. > >Does that clear anything up? > >-- >"Actually, I'm sitting on my butt staring at a computer screen." > - Tom Tomorrow > >j. > > > > Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
28. Re: Coming From QBasic
- Posted by "Lynn Kilroy" <leks_transportation at hotmail.com> Jan 18, 2006
- 546 views
Thanks! Lynn Erika Kilroy >From: Jeremy Peterson <guest at RapidEuphoria.com> >Reply-To: EUforum at topica.com >To: EUforum at topica.com >Subject: Re: Coming From QBasic >Date: Tue, 17 Jan 2006 10:30:01 -0800 > > >posted by: Jeremy Peterson <ptl99 at hotmail.com> > >Hey Lynn. You have to write graphics_mode. Its lowercase and Eu is case >sensitive. > >Jeremy > >Edmund Burke: "All that is necessary for evil to triumph is for good men to >do nothing." > > > >