Re: question converting to euphoria from qbasic

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

At Sat, 11 Apr 1998 09:22:41 EDT, ST Qu Man <STQuMan at AOL.COM> asked:
>how to transfer the following basic chunk to a Euphoria chunk.
>
>OPEN "c:\file.txt" FOR OUTPUT AS #1
>DO
>IF EOF(1) THEN GOTO 1090
>LINE INPUT #1, d$
>PRINT d$
>LOOP
>1090 SLEEP
>END

Assuming OUTPUT is changed to INPUT, all the solutions that have been
posted by BASIC-as-well-as-Euphoria programmers here [blink] seem to be
correct (I haven't tried them though), but then I noticed:

At Sun, 12 Apr 1998 18:02:08 GMT, Jeff Zeitlin
<jeff.zeitlin at MAIL.EXECNET.COM> replied:
>Really, what you're doing is reading each line of the file and
>printing it to the screen - essentially, the equivalent of the
>DOS built-in TYPE command.

So I thought I'd offer a simpler one-command replacement:

    system("type c:\\file.txt", 1)  -- bonus: beep and clear screen blink

Since that doesn't do the task nicely (it clears the screen), how about a
two-command one:

    system("type c:\\file.txt", 2)
    system("pause >nul", 2)

If you can't afford two system calls, with three commands you can say:

    include get.e
    system("type c:\\file.txt", 2)
    abort(wait_key())   -- this will also abort the program

If you don't want to abort the system call and don't want to use the DOS
pause command, you need four commands:

    include get.e
    integer i
    system("type c:\\file.txt", 2)
    i = wait_key()

Why do I prefer using system? Because I haven't registered Euphoria, I
can't afford it (how about my suggestion on having an Euphoria programming
contest, a really nice award is a registered version of Euphoria and I
really want it), and I have to constantly find tricks to keep my programs
having as few statements as possible (because 300 is just too small a limit
to let me program freely and creatively).

Note that there is a difference between all the Euphoria implementations
(including above) and the OUT-to-IN fixed QBasic program: the SLEEP command
will wait for a key (it does not return it, but it does not matter), and
you can even wake up from the SLEEP command by using keys like Shift, Ctrl
or Alt, but this cannot be done easily in Euphoria [not with wait_key, nor
with system("pause")].
--> Any idea to have such a SLEEP command?

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

Search



Quick Links

User menu

Not signed in.

Misc Menu