Jump to content
IGNORED

@Savetz made a Chat program in Turbo Basic XL!


Recommended Posts

The Chat Server:

https://gist.github.com/tschak909/482725f078e08d456b7be670ddbddb07

 

import asyncio

writers = []

def forward(writer, addr, message):
    for w in writers:
        if w != writer:
            w.write(f"{addr!r}: {message!r}\n".encode())

async def handle(reader, writer):
    writers.append(writer)
    addr = writer.get_extra_info('peername')
    message = f"{addr!r} is connected !!!!"
    print(message)
    forward(writer, addr, message)
    while True:
        data = await reader.read(100)
        message = data.decode().strip()
        forward(writer, addr, message)
        await writer.drain()
        if message == "exit":
            message = f"{addr!r} wants to close the connection."
            print(message)
            forward(writer, "Server", message)
            break
    writers.remove(writer)
    writer.close()

async def main():
    server = await asyncio.start_server(
        handle, '127.0.0.1', 8888)
    addr = server.sockets[0].getsockname()
    print(f'Serving on {addr}')
    async with server:
        await server.serve_forever()

asyncio.run(main())

 

  • Like 1
Link to comment
Share on other sites

A few observations / questions:

  • Other than a few DPEEK commands, and the MOVE command, I don't think it's using any Turbo BASIC commands; this could probably be translated to regular BASIC fairly easily.
  • Line 9000 appears to have an error - it refers to line 8396, which does not exist in the listing.  (On further examination, I'm wondering if line 9000 is used at all?)
  • Line 8400 TRAPs line 40000, which doesn't exist.

 

Link to comment
Share on other sites

1 minute ago, David_P said:

A few observations / questions:

  • Other than a few DPEEK commands, and the MOVE command, I don't think it's using any Turbo BASIC commands; this could probably be translated to regular BASIC fairly easily.
  • Line 9000 appears to have an error - it refers to line 8396, which does not exist in the listing.  (On further examination, I'm wondering if line 9000 is used at all?)
  • Line 8400 TRAPs line 40000, which doesn't exist.

 

Quite correct.

Line 9000 is old code, isn't used.

Line 40000 is the way to disable a TRAP.

 

-Thom

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...