hey

  • 12 Replies
  • 2199 Views
*

Zero

  • Eve
  • ***********
  • 1287
hey
« on: December 11, 2019, 05:19:47 pm »
hi guys
I'm back

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6855
  • Mostly Harmless
Re: hey
« Reply #1 on: December 11, 2019, 05:22:17 pm »
Welcome back Zero  :)

*

Zero

  • Eve
  • ***********
  • 1287
Re: hey
« Reply #2 on: December 11, 2019, 05:50:25 pm »
How are you Freddy? :)

*

ivan.moony

  • Trusty Member
  • ************
  • Bishop
  • *
  • 1722
    • mind-child
Re: hey
« Reply #3 on: December 11, 2019, 06:09:42 pm »
Hi  :)

Long time no see...

Are there any cool projects?

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6855
  • Mostly Harmless
Re: hey
« Reply #4 on: December 11, 2019, 06:20:09 pm »
How are you Freddy? :)

I'm good thanks, not doing much programming at the moment, but have a new game to work on when I get some free time. It's in the coming up with ideas stage.

Got anything you are working on now?

*

Zero

  • Eve
  • ***********
  • 1287
Re: hey
« Reply #5 on: December 11, 2019, 06:54:17 pm »
Not really... Hi Ivan :)

Right now I'm screwing around, downgrading Javascript so it looks like 80's unstructured BASIC.

Sticking this into an .html file:

Code
<!DOCTYPE html>
<html>
<head>
    <title>BASIC</title>
    <meta charset="utf-8">
    <style>
        html, body, body * {
            background: #005;
            color: #db9;
            font-family: Consolas, 'Lucida console', monospace, monospace;
            margin: 0;
            padding: 0;
            font-size: 16px;
            overflow-x: hidden;
            scrollbar-color: #444 transparent !important;
        }
        #term-output {
            white-space: pre-wrap;
        }
        #term-input {
            border: none;
            width: 100vw;
        }
    </style>
    <style id="paper-style">
        html, body, body * {}
    </style>
</head>
<body>
    <pre id="term-output"></pre><input type="text" id="term-input">

    <script>

    String.prototype.regexIndexOf = function(regex, startpos) {
        var indexOf = this.substring(startpos || 0).search(regex);
        return (indexOf >= 0) ? (indexOf + (startpos || 0)) : indexOf;
    }       

    var BASIC = {};
    var that;

    BASIC.color = "#db9";

    BASIC.program = {},
    BASIC.progPointer = "stop",
    BASIC.nextProgPointer = "stop";

    BASIC.subStack = [];

    const rem = function() {}

    const print = function(rawtxt) {

        var txt = (typeof rawtxt == "string" || typeof rawtxt == "number") ? rawtxt : JSON.stringify(rawtxt);
        BASIC.termOutput.innerHTML += `\n<span style="color:${BASIC.color};">${txt}</span>`;
        window.scrollTo(0,document.body.scrollHeight);
    }

    const pen = function(c) {

        BASIC.color = c;
    }

    const paper = function(b) {

        BASIC.paperStyle.innerHTML = `html, body, body * { background: ${b};}`;
    }

    const edit = function(lineNumber, instruction) {

        if (typeof instruction == "undefined") {

            BASIC.termInput.value = lineNumber+' '+BASIC.program[lineNumber];

        } else {

            BASIC.program[lineNumber] = instruction.trim();
        }
    }

    const run = function(start) {

        BASIC.progPointer = BASIC.orderedLines().filter(l => l >= (start || 0))[0];
       
        while (BASIC.progPointer) {
            BASIC.nextProgPointer = BASIC.orderedLines().filter(l => l > BASIC.progPointer)[0];
            that = BASIC.execute(BASIC.program[BASIC.progPointer]);
            BASIC.progPointer = BASIC.nextProgPointer;
        }

        BASIC.progPointer = "stop";
    }

    const goto = function(n) {

        BASIC.nextProgPointer = BASIC.orderedLines().filter(l => l >= n)[0];
    }

    const gosub = function(n) {

        BASIC.subStack.push(BASIC.progPointer);
        BASIC.nextProgPointer = BASIC.orderedLines().filter(l => l >= n)[0];
    }

    const end = function(n) {

        var previous = BASIC.subStack.pop();
        BASIC.nextProgPointer = BASIC.orderedLines().filter(l => l > previous)[0];
    }

    const list = function(rawStart, rawEnd) {

        var lineList = BASIC.orderedLines();
       
        var start = rawStart || lineList[0];
        var end = rawEnd || lineList[lineList.length-1];

        lineList.filter(l => l >= start && l <= end).forEach(l => { print(l+' '+BASIC.program[l]); });
    }

    const cls = function() {
        BASIC.termOutput.innerHTML = '';
    }

    BASIC.execute = function(rawloc) {

        var result;
        var loc = rawloc+' ';

        try {
            var verb = loc.substr(0, loc.regexIndexOf(/[ =]/));
            var args = eval('['+loc.substr(verb.length)+']');
            result = eval(verb).apply(null, args);
            var success = true;
        } catch(e) {}
        if (!success) {
            try{
                result = eval(loc);
            } catch(e) {
                print((BASIC.progPointer == "stop" ? '' : `line ${BASIC.progPointer}, `) + e.message);
            }
        }
        return result;
    }

    BASIC.evalInput = function(cmd) {

        print(cmd);
        BASIC.termInput.value = '';

        var first = cmd.substr(0, cmd.indexOf(' '));
        var lineNumber = parseInt(first);
        if (first.length > 0 && !isNaN(lineNumber)) {

            edit(lineNumber, cmd.substr(first.length));

        } else {

            that = BASIC.execute(cmd);
            print("Ready");
            BASIC.termInput.focus();
        }
    }

    BASIC.orderedLines = function() {
        return Object.keys(BASIC.program).map(t => parseInt(t)).sort((a,b)=>{a<b});
    }

    BASIC.termInput = document.getElementById("term-input");
    BASIC.termOutput = document.getElementById("term-output");
    BASIC.paperStyle = document.getElementById("paper-style");
   
    BASIC.termInput.addEventListener("keyup", function(event) {

        if (event.key === "Enter") BASIC.evalInput(BASIC.termInput.value);
    });

    window.onclick = function() {
       
        BASIC.termInput.focus();
    }

    print("Ready");
    BASIC.termInput.focus();

    </script>
</body>
</html>

... you'd get an interpreter able to take a program like:


10 x = 1
20 gosub 100
30 x = x+1
40 if (x < 20) goto(20)
50 goto 200
100 print x
110 end
200 print "that's all folks"


...as I said, just screwin around.

*

Zero

  • Eve
  • ***********
  • 1287
Re: hey
« Reply #6 on: December 11, 2019, 06:56:12 pm »
what the game about?

*

HS

  • Trusty Member
  • **********
  • Millennium Man
  • *
  • 1175
Re: hey
« Reply #7 on: December 11, 2019, 07:05:43 pm »
Hey, Zero. 

*

Zero

  • Eve
  • ***********
  • 1287
Re: hey
« Reply #8 on: December 11, 2019, 07:12:16 pm »
Hi Hope ;)

Hey guys, where's Ranch?

*

Freddy

  • Administrator
  • **********************
  • Colossus
  • *
  • 6855
  • Mostly Harmless

*

Korrelan

  • Trusty Member
  • ***********
  • Eve
  • *
  • 1454
  • Look into my eyes! WOAH!
    • YouTube
Re: hey
« Reply #10 on: December 11, 2019, 09:12:25 pm »
Yo... Z

 :)
It thunk... therefore it is!...    /    Project Page    /    KorrTecx Website

*

Art

  • At the end of the game, the King and Pawn go into the same box.
  • Moderator
  • **********************
  • Colossus
  • *
  • 5865
Re: hey
« Reply #11 on: December 12, 2019, 03:39:16 am »
Hey Zero! Nice to see you!
In the world of AI, it's the thought that counts!

*

Zero

  • Eve
  • ***********
  • 1287
Re: hey
« Reply #12 on: December 12, 2019, 09:30:06 am »
Hello friends, it's nice to be back.

 


Say good-bye to GPUs...
by MikeB (AI News )
March 23, 2024, 09:23:52 am
OpenAI Speech-to-Speech Reasoning Demo
by MikeB (AI News )
March 15, 2024, 08:14:02 am
Google Bard report
by ivan.moony (AI News )
February 14, 2024, 04:42:23 pm
Elon Musk's xAI Grok Chatbot
by MikeB (AI News )
December 11, 2023, 06:26:33 am
Nvidia Hype
by 8pla.net (AI News )
December 06, 2023, 10:04:52 pm
How will the OpenAI CEO being Fired affect ChatGPT?
by 8pla.net (AI News )
December 06, 2023, 09:54:25 pm
Independent AI sovereignties
by WriterOfMinds (AI News )
November 08, 2023, 04:51:21 am
LLaMA2 Meta's chatbot released
by 8pla.net (AI News )
October 18, 2023, 11:41:21 pm

Users Online

290 Guests, 0 Users

Most Online Today: 320. Most Online Ever: 2369 (November 21, 2020, 04:08:13 pm)

Articles