Piznium random utilities/Functions test code/1

This version done 19 march 2022 4:52 UTC (works perfectly, and yes, piznium is being rewrote from the ground up) function splitStr(inputstr,sep) local t = {} for str in string.gmatch(inputstr,"([^"..sep.."]+)") do   table.insert(t, str) end return t end

function tableLength(table) local length = 0 for i in pairs(table) do   length = length + 1 end return length end

function displayTable(table) io.write("{") local lenOfTable = tableLength(table) for i in pairs(table) do   if i == lenOfTable then io.write("\"" .. table[i] .. "\"") else io.write("\"" .. table[i] .. "\",") end end io.write("}") end

-- Piznium indice getter test

function getIndiceData(toget) local splitted = splitStr(toget,"[") splitted[2] = string.sub(splitted[2],1,-2) return splitted end

-- Number detector function tableContains(table, element) for i in pairs(table) do   if table[i] == element then return true end end return false end

local zeroToNine = {"0","1","2","3","4","5","6","7","8","9"}

function verifyNumber(number) local gotSoFar = {} local thisChar = "" local decimalCount = 0 for i = 1, #number do   thisChar = string.sub(number,i,i) if tableContains(zeroToNine,thisChar) then table.insert(gotSoFar,"pass") elseif thisChar == "." then if decimalCount > 0 then table.insert(gotSoFar,"decimalTooMany") else table.insert(gotSoFar,"decimal") end decimalCount = decimalCount + 1 else table.insert(gotSoFar,"fail") end end return gotSoFar end

function isValidNumber(number) return verifyNumber(number) -- It's coming soon so yeah end

-- Data storing system functions test function getByStored(toget) local firstChar = string.sub(toget,1,1) local otherChars = string.sub(toget,2,-1) if firstChar == "n" then return {"str",otherChars,"Normal string","stringLike"} elseif firstChar == "f" then return {"fstr",otherChars,"Formatted string","stringLike"} elseif firstChar == "u" then return {"unif",otherChars,"Unified value","stringLike"} elseif toget == "g-" then return {"gnric","null","Null","normalGeneric"} elseif toget == "g?" then return {"gnric","unk","Unknown value","normalGeneric"} elseif toget == "g0" then return {"gnric","nnull","Null (numeric)","numeric"} elseif toget == "g8" then return {"gnric","inf","Infinity","numeric"} elseif toget == "gn" then return {"bool","neu","Neutral","boolGeneric"} elseif toget == true then return {"bool","true","True","boolGeneric"} elseif toget == false then return {"bool","false","False","boolGeneric"} elseif isValidNumber(toget) == "w" then return {"num",toget,"Number","numericWhole"} elseif isValidNumber(toget) == "d" then return {"num",toget,"Number","numericDecimal"} else return "invalid" end -- Function returns a table -- First item = what type is it -- Second item = what data it has -- Third item = display name for ui elements -- Fourth item = group/more information end

-- Comment and unneeded space removal function removeUnneededSpaces(funcAsString) -- Removes indents and trailing spaces, which if not removed could cause some issues return string.gsub(funcAsString,"^%s*(.-)%s*$", "%1") end

function charPosition(given,need) return splitStr(string.find(given,need),"   ")[1] end

function positionOfComment(funcAsString) if string.find(funcAsString,"#") then return charPosition(funcAsString,"#") else return 0 end end

function removeComment(funcAsString) local commentPos = positionOfComment(funcAsString) if commentPos == 0 then return funcAsString else return string.sub(funcAsString,1,commentPos - 1) end end

-- Normal function splitter/param getter function splitFunc(funcAsString) local splitted = splitStr(funcAsString,"(") splitted[2] = string.sub(splitted[2],1,-2)  local params = splitStr(splitted[2],",")  splitted = splitStr(splitted[1],".")  local module = "Main"  local command = ""  if tableLength(splitted) == 1 then    command = splitted[1]  else    module = splitted[1]    command = splitted[2]  end  table.remove(splitted,1)  table.remove(splitted,1)  return {module,command,splitted,params} end

function runNormalFunc(funcAsString) -- "func" in here refers to "FUNCtion" -- Get data of function local gotFuncData = splitFunc(removeUnneededSpaces(removeComment(funcAsString))) local module = gotFuncData[1] local command = gotFuncData[2] local moreName = gotFuncData[3] local params = gotFuncData[4] -- Now actually run if module == "Main" then end end

runNormalFunc("hey.d.Statistica(stoppings!,OH NO...,) # jetment")