1. Line Generator

------=_NextPart_000_0007_01C018E5.F0E6AA40
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Can anyone tell me why I'm getting an error from this:

include get.e

atom desc

desc=3Dgets(0)
? desc
desc=3Ddesc[1]
? desc
while desc>0 do
    puts(1,"!")
end while


I'm making a program that generates lines according to what they type =
in, but I need the enter ereased but not all the other numbers.

-Thanks.
-Thomas



------=_NextPart_000_0007_01C018E5.F0E6AA40
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Can anyone tell me why I'm getting an =
error from=20
this:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>include get.e</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>atom desc</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>desc=3Dgets(0)<BR>? =
desc<BR>desc=3Ddesc[1]<BR>?=20
desc<BR>while desc&gt;0 do<BR>&nbsp;&nbsp;&nbsp; puts(1,"!")<BR>end=20
while</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I'm making a program that generates =
lines according=20
to what they type in, but I need the enter ereased but not all the other =

numbers.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-Thanks.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>-Thomas</FONT></DIV>

------=_NextPart_000_0007_01C018E5.F0E6AA40--

new topic     » topic index » view message » categorize

2. Re: Line Generator

------=_NextPart_000_0014_01C01934.044B2040
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Thomas,

desc should be an object, since gets(0) returns a sequence of 2 atoms.
  ----- Oorspronkelijk bericht -----=20
  Van: Paul Kerslake=20
  Aan: EUPHORIA at LISTSERV.MUOHIO.EDU=20
  Verzonden: vrijdag 8 september 2000 1:09
  Onderwerp: Line Generator


  Can anyone tell me why I'm getting an error from this:

  include get.e

  atom desc

  desc=3Dgets(0)
  ? desc
  desc=3Ddesc[1]
  ? desc
  while desc>0 do
      puts(1,"!")
  end while

  =20
  I'm making a program that generates lines according to what they type =
in, but I need the enter ereased but not all the other numbers.

  -Thanks.
  -Thomas

  =20

------=_NextPart_000_0014_01C01934.044B2040
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2314.1000" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV>Thomas,</DIV>
<DIV>&nbsp;</DIV>
<DIV>desc should be an object, since gets(0) returns a sequence of 2=20
atoms.</DIV>
<BLOCKQUOTE=20
style=3D"BORDER-LEFT: #000000 2px solid; MARGIN-LEFT: 5px; MARGIN-RIGHT: =
0px; PADDING-LEFT: 5px; PADDING-RIGHT: 0px">
  <DIV style=3D"FONT: 10pt arial">----- Oorspronkelijk bericht ----- =
</DIV>
  <DIV=20
  style=3D"BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: =
black"><B>Van:</B>=20
  <A href=3D"mailto:paulk at UNISERVE.COM" title=3Dpaulk at UNISERVE.COM>Paul =
Kerslake</A>=20
  </DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Aan:</B> <A=20
  href=3D"mailto:EUPHORIA at LISTSERV.MUOHIO.EDU"=20
  title=3DEUPHORIA at LISTSERV.MUOHIO.EDU>EUPHORIA at LISTSERV.MUOHIO.EDU</A> =
</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Verzonden:</B> vrijdag 8 september =
2000=20
  1:09</DIV>
  <DIV style=3D"FONT: 10pt arial"><B>Onderwerp:</B> Line Generator</DIV>
  <DIV><BR></DIV>
  <DIV><FONT face=3DArial size=3D2>Can anyone tell me why I'm getting an =
error from=20
  this:</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>include get.e</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>atom desc</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>desc=3Dgets(0)<BR>? =
desc<BR>desc=3Ddesc[1]<BR>?=20
  desc<BR>while desc&gt;0 do<BR>&nbsp;&nbsp;&nbsp; puts(1,"!")<BR>end=20
  while</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>I'm making a program that generates =
lines=20
  according to what they type in, but I need the enter ereased but not =
all the=20
  other numbers.</FONT></DIV>
  <DIV>&nbsp;</DIV>
  <DIV><FONT face=3DArial size=3D2>-Thanks.</FONT></DIV>
  <DIV><FONT face=3DArial size=3D2>-Thomas</FONT></DIV>
  <DIV><FONT face=3DArial =

------=_NextPart_000_0014_01C01934.044B2040--

new topic     » goto parent     » topic index » view message » categorize

3. Re: Line Generator

------=_NextPart_000_000B_01C0197E.55858000
        charset="iso-8859-1"

Hi Thomas,
there are two problems here.

1)  GETS() returns a SEQUENCE, but you have defined 'desc' as an ATOM.

2) The loop will never end, because the value of 'desc' doesn't change
inside the loop.

-----
cheers,
Derek Parnell
derekp at solace.com.au
Solace Limited ( http://www.solace.com.au )
Melbourne, Australia
+61 3 9291 7557

new topic     » goto parent     » topic index » view message » categorize

4. Re: Line Generator

On Thu, 07 Sep 2000, you wrote:
>
> Thomas,
>
> desc should be an object, since gets(0) returns a sequence of 2 atoms.

gets reads a line from a file. You probably want get, which returns a
sequence {success, value}. success would be GET_SUCCESS on success, and the
value is whatever value it read. Also note that since you're not modifying desc
in the loop, you will get an infinate loop if desc is greater than 0.

Jeff

>   ----- Oorspronkelijk bericht -----
>   Van: Paul Kerslake
>   Aan: EUPHORIA at LISTSERV.MUOHIO.EDU
>   Verzonden: vrijdag 8 september 2000 1:09
>   Onderwerp: Line Generator
>
>
>   Can anyone tell me why I'm getting an error from this:
>
>   include get.e
>
>   atom desc
>
>   desc=gets(0)
>   ? desc
>   desc=desc[1]
>   ? desc
>   while desc>0 do
>       puts(1,"!")
>   end while
>
>
>   I'm making a program that generates lines according to what they type in,
>   but I need the enter ereased but not all the other numbers.
>
>   -Thanks.
>   -Thomas
>
>
>
>
>

----------------------------------------
Content-Description:
----------------------------------------

new topic     » goto parent     » topic index » view message » categorize

5. Re: Line Generator

On Thu, 7 Sep 2000 16:09:03 -0700, Paul Kerslake wrote:

>Can anyone tell me why I'm getting an error from this:
>
>include get.e
>
>atom desc
>
>desc=gets(0)
>? desc
>desc=desc[1]
>? desc
>while desc>0 do
>    puts(1,"!")
>end while
>
>
>I'm making a program that generates lines according to what they type in,
but I need the enter ereased but not all the other numbers.
>
>-Thanks.
>-Thomas

You might want to read the Euphoria Reference Manual over again:

Because either a sequence or an atom (-1) might be returned by gets(), you
should probably assign the result to a variable declared as object.

That being said, you might try something like:

include get.e

object desc

desc=gets(0)
? desc

if sequence( desc ) then           -- user did not hit Ctrl-Z
  desc = desc[1..length(desc)-1]   -- remove last element from sequence
end if
? desc

-- I'm not sure what you are trying to do below since 'desc' is a sequence
--   unless we've hit 'end of file' or Ctrl-Z

--while desc>0 do
--    puts(1,"!")
--end while

-------------------------

Perhaps if you provide more details of what you'd really like to do, then
we could suggest some other, possibly better solutions.

-- Brian

new topic     » goto parent     » topic index » view message » categorize

6. Re: Line Generator

------=_NextPart_000_0055_01C018FE.35A772A0
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


----- Original Message -----=20
From: Brian Broker <bkb at CNW.COM>
To: <EUPHORIA at LISTSERV.MUOHIO.EDU>
Sent: Thursday, September 07, 2000 4:35 PM
Subject: Re: Line Generator


> On Thu, 7 Sep 2000 16:09:03 -0700, Paul Kerslake wrote:
>=20
> >Can anyone tell me why I'm getting an error from this:
> >
> >include get.e
> >
> >atom desc
> >
> >desc=3Dgets(0)
> >? desc
> >desc=3Ddesc[1]
> >? desc
> >while desc>0 do
> >    puts(1,"!")
> >end while
> >
> >
> >I'm making a program that generates lines according to what they type =
in,
> but I need the enter ereased but not all the other numbers.
> >
> >-Thanks.
> >-Thomas
>=20
> You might want to read the Euphoria Reference Manual over again:
>=20
> Because either a sequence or an atom (-1) might be returned by gets(), =
you
> should probably assign the result to a variable declared as object.
>=20
> That being said, you might try something like:
>=20
> include get.e
>=20
> object desc
>=20
> desc=3Dgets(0)
> ? desc
>=20
> if sequence( desc ) then           -- user did not hit Ctrl-Z
>   desc =3D desc[1..length(desc)-1]   -- remove last element from =
sequence
> end if
> ? desc
>=20
> -- I'm not sure what you are trying to do below since 'desc' is a =
sequence
> --   unless we've hit 'end of file' or Ctrl-Z
>=20
> --while desc>0 do
> --    puts(1,"!")
> --end while
>=20
> -------------------------
>=20
> Perhaps if you provide more details of what you'd really like to do, =
then
> we could suggest some other, possibly better solutions.
>=20
> -- Brian

What I'm REALLY working on is:

include get.e
include graphics.e

integer gmode
gmode=3Dgraphics_mode(19)

puts(1,"            Enter a Number from one to nine.")
procedure grolin()
    atom ul,ll,ur,lr,lcol
    object desc
    desc=3Dgets(0)
    desc=3Ddesc[1..2] -- I'd like the numbers entered, not the ENTER key
    while desc>0 do
    lcol=3Drand(15)
    ul=3Drand(100)
    ll=3Drand(100)
    ur=3Drand(100)
    lr=3Drand(100)
    draw_line(lcol,{{ul,ll},{ur,lr}})
    desc-=3D1
    end while
end procedure

That's it. The [1..2] bit is a bit confusing, I want the user to be able =
to enter any number and grolin() will run through once for each number =
entered. ie: 53 - run through it 53 times.
oh yeah, is there a way to play a procedure more than once besides =
writing it twice?

-Thanks
-Thomas

------=_NextPart_000_0055_01C018FE.35A772A0
        charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.2614.3500" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>----- Original Message ----- </FONT>
<DIV><FONT face=3DArial size=3D2>From: Brian Broker &lt;<A=20
<DIV><FONT face=3DArial size=3D2>To: &lt;<A=20
</A>&gt;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Sent: Thursday, September 07, 2000 4:35 =

PM</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Subject: Re: Line =
Generator</FONT></DIV></DIV>
<DIV><BR></DIV>
<DIV><FONT face=3DArial size=3D2>&gt; On Thu, 7 Sep 2000 16:09:03 -0700, =
Paul=20
Kerslake wrote:<BR>&gt; <BR>&gt; &gt;Can anyone tell me why I'm getting =
an error=20
from this:<BR>&gt; &gt;<BR>&gt; &gt;include get.e<BR>&gt; &gt;<BR>&gt; =
&gt;atom=20
desc<BR>&gt; &gt;<BR>&gt; &gt;desc=3Dgets(0)<BR>&gt; &gt;? desc<BR>&gt;=20
&gt;desc=3Ddesc[1]<BR>&gt; &gt;? desc<BR>&gt; &gt;while desc&gt;0 =
do<BR>&gt;=20
&gt;&nbsp;&nbsp;&nbsp; puts(1,"!")<BR>&gt; &gt;end while<BR>&gt; =
&gt;<BR>&gt;=20
&gt;<BR>&gt; &gt;I'm making a program that generates lines according to =
what=20
they type in,<BR>&gt; but I need the enter ereased but not all the other =

numbers.<BR>&gt; &gt;<BR>&gt; &gt;-Thanks.<BR>&gt; &gt;-Thomas<BR>&gt; =
<BR>&gt;=20
You might want to read the Euphoria Reference Manual over again:<BR>&gt; =

<BR>&gt; Because either a sequence or an atom (-1) might be returned by =
gets(),=20
you<BR>&gt; should probably assign the result to a variable declared as=20
object.<BR>&gt; <BR>&gt; That being said, you might try something =
like:<BR>&gt;=20
<BR>&gt; include get.e<BR>&gt; <BR>&gt; object desc<BR>&gt; <BR>&gt;=20
desc=3Dgets(0)<BR>&gt; ? desc<BR>&gt; <BR>&gt; if sequence( desc )=20
then&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -- user =
did not=20
hit Ctrl-Z<BR>&gt; &nbsp; desc =3D desc[1..length(desc)-1]&nbsp;&nbsp; =
-- remove=20
last element from sequence<BR>&gt; end if<BR>&gt; ? desc<BR>&gt; =
<BR>&gt; -- I'm=20
not sure what you are trying to do below since 'desc' is a =
sequence<BR>&gt;=20
--&nbsp;&nbsp; unless we've hit 'end of file' or Ctrl-Z<BR>&gt; <BR>&gt; =
--while=20
desc&gt;0 do<BR>&gt; --&nbsp;&nbsp;&nbsp; puts(1,"!")<BR>&gt; --end=20
while<BR>&gt; <BR>&gt; -------------------------<BR>&gt; <BR>&gt; =
Perhaps if you=20
provide more details of what you'd really like to do, then<BR>&gt; we =
could=20
suggest some other, possibly better solutions.<BR>&gt; <BR>&gt; --=20
Brian</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>What I'm REALLY working on =
is:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>include get.e<BR>include =
graphics.e</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>integer=20
gmode<BR>gmode=3Dgraphics_mode(19)</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial=20
bsp;&nbsp;=20
Enter a Number from one to nine.")<BR>procedure =
grolin()<BR>&nbsp;&nbsp;&nbsp;=20
atom ul,ll,ur,lr,lcol<BR>&nbsp;&nbsp;&nbsp; object =
desc<BR>&nbsp;&nbsp;&nbsp;=20
desc=3Dgets(0)<BR>&nbsp;&nbsp;&nbsp; desc=3Ddesc[1..2] <FONT size=3D3>-- =
I'd like the=20
numbers entered, not the ENTER key<BR>&nbsp;&nbsp;&nbsp; </FONT>while =
desc&gt;0=20
do<BR>&nbsp;&nbsp;&nbsp; lcol=3Drand(15)<BR>&nbsp;&nbsp;&nbsp;=20
ul=3Drand(100)<BR>&nbsp;&nbsp;&nbsp; =
ll=3Drand(100)<BR>&nbsp;&nbsp;&nbsp;=20
ur=3Drand(100)<BR>&nbsp;&nbsp;&nbsp; =
lr=3Drand(100)<BR>&nbsp;&nbsp;&nbsp;=20
desc-=3D1<BR>&nbsp;&nbsp;&nbsp; end while<BR>end procedure</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>That's it. The [1..2] bit is a bit =
confusing, I=20
want the user to be able to enter any number and grolin() will run =
through once=20
for each number entered. ie: 53 - run through it 53 times.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>oh yeah, is there a way to play a =
procedure more=20
than once besides writing it twice?</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>-Thanks</FONT></DIV>

------=_NextPart_000_0055_01C018FE.35A772A0--

new topic     » goto parent     » topic index » view message » categorize

7. Re: Line Generator

On Thu, 7 Sep 2000 19:02:46 -0700, Thomas wrote:

>What I'm REALLY working on is:

<snipped program to save space>

>oh yeah, is there a way to play a procedure more than once besides writing
>it twice?

Absolutely, that's the whole purpose of using procedures and functions...
it's re-usable code.

As for your program, I think that Euphoria's 'prompt_number' function fits
well in a program like this.  Below I give further suggestions in my
comments.  I wasn't sure what you wanted to do with 'grolin' (changed
to 'groline' because I kept adding an 'e' to the end of it) so I provided
two versions.  Just change the 'groline1' to 'groline2' in the MAIN PROGRAM
section at the bottom to see the other version (what I thought you might
have wanted based on the name of the procedure).  I hope I'm not taking the
fun out of experimenting by 'giving my version', I'm just hoping to give
you ideas...  (you can take it anywhere you'd like to from here)


-- grolin.ex --
include get.e
include graphics.e

-- use constants to define the screen resolution, so if you
--  change the resolution, you only have to change these
--  two numbers at the top of your program
constant
  Max_X = 320,
  Max_Y = 200

integer desc

integer gmode
--gmode = graphics_mode(19)

-- try to set graphics mode to 320 x 200, 256 color

-- set graphics mode, exit if we've failed to do so
if graphics_mode(19) then
  puts( 1, "unable to set graphics mode...\n" )
  abort(1)  -- exit program with error code = 1
end if

-- Define your procedures and functions before the main program
--  just like you would with constants and variables
-- Procedures and functions are re-usable, this is the reason for
--  their existance
procedure groline1( integer n )
  --atom ul,ll,ur,lr,lcol
  integer lcolor
  sequence point1, point2

  -- start by clearing screen
  clear_screen()

-- NOTE: this looks like a job for 'prompt_number' (see above)
  --desc=gets(0)
  --desc=desc[1..2]   -- I'd like the numbers entered, not the ENTER key

  --while desc>0 do
  for i = 1 to n do -- easiest to use a 'for' loop in this case
    lcolor = rand(14)+1  -- add one since color 0 = black (can't see it)
    --ul=rand(100)
    --ll=rand(100)
    -- NOTE: you can put these in a sequence to pass in draw_line
    --  use your constants so that the end points are contained on screen
    point1 = { rand(Max_X), rand(Max_Y) }
    --ur=rand(100)
    --lr=rand(100)
    point2 = { rand(Max_X), rand(Max_Y) }
    --draw_line(lcol,{{ul,ll},{ur,lr}})
    draw_line( lcolor, {point1, point2} )
    --desc-=1
  end for

  -- wait for user input before we put text over the lines
  if wait_key() then end if  -- an empty if/then gets me out of assigning
                             --  the result of wait_key() to a variable
end procedure

procedure groline2( integer n )
  integer lcolor
  sequence lastpt, nextpt

  clear_screen()

  lastpt = { rand(Max_X), rand(Max_Y) }
  for i = 1 to n do
    nextpt = { rand(Max_X), rand(Max_Y) }
    lcolor = rand(14)+1
    draw_line( lcolor, {lastpt, nextpt} )
    lastpt = nextpt
  end for

  if wait_key() then end if

end procedure

-- MAIN PROGRAM STARTS HERE --
--puts(1,"            Enter a Number from one to nine.")

while 1 do
  desc = prompt_number( "Enter a number from one to fifty...\n" &
                        "(enter zero to exit program): ", {0,50} )
  if desc then -- if desc != 0 then run procedure 'groline'
    groline1( desc )  -- 'desc' gets passed to groline()
  else                -- (which is variable 'n' in groline)
    gmode = graphics_mode(-1) -- otherwise restore graphics mode
    exit                      -- and exit while loop
  end if
end while
-- END MAIN PROGRAM --

-- have fun!!!
-- Brian

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu