(lots of changes here)
Firstly, these can all be found in "testing3.html"
I split them up to make it easier to manage.
Because the interpreter was getting a bit large, I added an extra "extended-functions.js" which is called as an extension of the interpreter now. Just means that as the file grows in size, we can add extras coming off it. (I was getting too confused by the size of the "interpreter.js" and it was getting difficult to make changes).
Mentioning that, I've been busy adding the following functions:
Examples:
Format function
Code: Select all
put format(123.456, "#.#") into tResult
put tResult -- outputs 123.5
Code: Select all
put baseConvert(255, 10, 16) into tResult
put tResult -- would output ff
Code: Select all
put pi() into tResult
put tResult -- outputs 3.141592653589793
Code: Select all
put variance("1,2,3,4,5") into tResult
put tResult -- outputs 2
Code: Select all
put "1,2,3,4,5" into tNumbers
put variance(tNumbers) into tResult
put tResult -- outputs 2
Code: Select all
put standardDeviation("1,2,3,4,5") into tResult
put tResult -- outputs 1.4142135623730951
Code: Select all
put "a,b,c" into tList1
put "c,d,e" into tList2
put union(tList1, tList2) into tResult
put tResult -- outputs a,b,c,d,e
Code: Select all
put "a,b,c" into tList1
put "c,d,e" into tList2
put intersection(tList1, tList2) into tResult
put tResult -- outputs c
Code: Select all
put split("a-b-c", "-") into tResult
put tResult -- outputs a,b,c
Code: Select all
put "a,b,c" into tList1
put "-" into tDelimiter -- new delimiter to put between items of tList1
put join(tList1, tDelimiter) into tResult
put tResult -- outputs a-b-c
Code: Select all
put base64Encode("Hello, World!") into tResult
put tResult -- returns SGVsbG8sIFdvcmxkIQ==
Code: Select all
put base64Decode("SGVsbG8sIFdvcmxkIQ==") into tResult
put tResult -- returns Hello, World!
Code: Select all
put md5Digest("Hello, World!") into tResult
put tResult
-- outputs: 06050a080e02070d080807090208030803010b0606040b0d080b070f000a0d04
Code: Select all
put sha1Digest("Hello, World!") into tResult
put tResult -- returns 0a0a9f2a6772942557ab5355-28950bbe-709a1ff
I modified the prototype of the InterpreterClass. This makes sure that wherever I include the interpreter, including the one in in main.js, it'll have access to the extended functions.
I've also added a transparent retry check that will attempt to extend the InterpreterClass multiple times if it's not available. (this silently prevents errors, and I thought it was better than adding any wait commands)
This support situations where the script loading order might not be right for example.
This means the interpreter now uses the original evaluateExpression as a function reference instead of a class inheritance. This should be more reliable for edits and changes when you want to see it in realtime.
I now have a headache and am going to take "a few days out" to reset my head.