1. QBasic to Euphoria

Hi everybody,

I'm new to Euphoria, and this mailing list.

I have this QBasic program I would like to translate to Euphoria.  Any ideas?

'Computes points earned by hockey teams.
CLS
INPUT "   TEAM:       ", team$ 'Enter team name.
INPUT "   WON :       ", won   'Number of games won.
INPUT "   LOST:       ", lost  'Number of games lost.
INPUT "   TIE :       ", tie   'Number of ties.
    points = won * 2 + tie     'Compute number of points.
PRINT "TEAM", " WON", " LOST", " TIE", " POINTS" 'Display results.
PRINT team$, won, lost, tie, points              'Display results.

Thanks in advance,
Steve Elder

new topic     » topic index » view message » categorize

2. Re: QBasic to Euphoria

include get.e --this is used for value() command

integer won, lost, tie, points  -- setup integers
sequence team, buffer  -- setup sequence   !similar to strings!

clear_screen()

puts(1, " TEAM: ")--PRINT "TEAM: ";
buffer = gets(0)-- get a sequence   !similar to a string!
team = buffer[1..length(buffer) - 1]-- put buffer into team without the
linefeed

puts(1, "\n WON: ")--PRINT "WON: ";
buffer = {1}-- set this so loop will start
while buffer[1] = 1 do--loops until valid value for won
  buffer = gets(0)
  buffer = value(buffer)
  if buffer[1] != 1 then
    won = buffer[2]--puts valid value into won
  else
    puts(1, "\n WON: ")
  end if
end while

puts(1, "\n LOST: ")
buffer = {1}
while buffer[1] = 1 do--loops until valid value for lost
  buffer = gets(0)
  buffer = value(buffer)
  if buffer[1] != 1 then
    lost = buffer[2]--puts valid value into lost
  else
    puts(1, "\n LOST: ")
  end if
end while

puts(1, "\n TIES: ")
buffer = {1}
while buffer[1] = 1 do--loops until valid value for lost
  buffer = gets(0)
  buffer = value(buffer)
  if buffer[1] != 1 then
    tie = buffer[2]--puts valid value into tie
  else
    puts(1, "\n TIES: ")
  end if
end while

points = won * 2 + tie    --Compute number of points.
puts(1, "\nTEAM\tWON\tLOST\tTIE\tPOINTS") --Display results.
printf(1, "\n%s\t%d\t%d\t%d\t%d", {team, won, lost, tie, points})

--that should do it       Lucius L. Hilley III

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

Search



Quick Links

User menu

Not signed in.

Misc Menu