02-14-2023, 03:36 PM
Code: (Select All)
Sub Set_OrderOfOperations
'PL sets our priortity level. 1 is highest to 65535 for the lowest.
'I used a range here so I could add in new priority levels as needed.
'OName ended up becoming the name of our commands, as I modified things.... Go figure! LOL!
'Constants get evaluated first, with a Priority Level of 1
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_PI"
ReDim _Preserve PL(i): PL(i) = 1
'I'm not certain where exactly percentages should go. They kind of seem like a special case to me. COS10% should be COS.1 I'd think...
'I'm putting it here for now, and if anyone knows someplace better for it in our order of operations, let me know.
i = i + 1: ReDim _Preserve OName(i): OName(i) = "%"
ReDim _Preserve PL(i): PL(i) = 5
'Then Functions with PL 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_ACOS"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_ASIN"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_ARCSEC"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_ARCCSC"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_ARCCOT"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_SECH"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_CSCH"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_COTH"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "COS"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "SIN"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "TAN"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "LOG"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "EXP"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "ATN"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_D2R"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_D2G"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_R2D"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_R2G"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_G2D"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_G2R"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "ABS"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "SGN"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "INT"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_ROUND"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "FIX"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_SEC"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_CSC"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "_COT"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "ASC"
ReDim _Preserve PL(i): PL(i) = 10
i = i + 1: ReDim _Preserve OName(i): OName(i) = "CHR$"
ReDim _Preserve PL(i): PL(i) = 10
'Exponents with PL 20
i = i + 1: ReDim _Preserve OName(i): OName(i) = "^"
ReDim _Preserve PL(i): PL(i) = 20
i = i + 1: ReDim _Preserve OName(i): OName(i) = "SQR"
ReDim _Preserve PL(i): PL(i) = 20
i = i + 1: ReDim _Preserve OName(i): OName(i) = "ROOT"
ReDim _Preserve PL(i): PL(i) = 20
'Multiplication and Division PL 30
i = i + 1: ReDim _Preserve OName(i): OName(i) = "*"
ReDim _Preserve PL(i): PL(i) = 30
i = i + 1: ReDim _Preserve OName(i): OName(i) = "/"
ReDim _Preserve PL(i): PL(i) = 30
'Integer Division PL 40
i = i + 1: ReDim _Preserve OName(i): OName(i) = "\"
ReDim _Preserve PL(i): PL(i) = 40
'MOD PL 50
i = i + 1: ReDim _Preserve OName(i): OName(i) = "MOD"
ReDim _Preserve PL(i): PL(i) = 50
'Addition and Subtraction PL 60
i = i + 1: ReDim _Preserve OName(i): OName(i) = "+"
ReDim _Preserve PL(i): PL(i) = 60
i = i + 1: ReDim _Preserve OName(i): OName(i) = "-"
ReDim _Preserve PL(i): PL(i) = 60
'Relational Operators =, >, <, <>, <=, >= PL 70
i = i + 1: ReDim _Preserve OName(i): OName(i) = "<>"
ReDim _Preserve PL(i): PL(i) = 70
i = i + 1: ReDim _Preserve OName(i): OName(i) = "><" 'These next three are just reversed symbols as an attempt to help process a common typo
ReDim _Preserve PL(i): PL(i) = 70
i = i + 1: ReDim _Preserve OName(i): OName(i) = "<="
ReDim _Preserve PL(i): PL(i) = 70
i = i + 1: ReDim _Preserve OName(i): OName(i) = ">="
ReDim _Preserve PL(i): PL(i) = 70
i = i + 1: ReDim _Preserve OName(i): OName(i) = "=<" 'I personally can never keep these things straight. Is it < = or = <...
ReDim _Preserve PL(i): PL(i) = 70
i = i + 1: ReDim _Preserve OName(i): OName(i) = "=>" 'Who knows, check both!
ReDim _Preserve PL(i): PL(i) = 70
i = i + 1: ReDim _Preserve OName(i): OName(i) = ">"
ReDim _Preserve PL(i): PL(i) = 70
i = i + 1: ReDim _Preserve OName(i): OName(i) = "<"
ReDim _Preserve PL(i): PL(i) = 70
i = i + 1: ReDim _Preserve OName(i): OName(i) = "="
ReDim _Preserve PL(i): PL(i) = 70
'Logical Operations PL 80+
i = i + 1: ReDim _Preserve OName(i): OName(i) = "NOT"
ReDim _Preserve PL(i): PL(i) = 80
i = i + 1: ReDim _Preserve OName(i): OName(i) = "AND"
ReDim _Preserve PL(i): PL(i) = 90
i = i + 1: ReDim _Preserve OName(i): OName(i) = "OR"
ReDim _Preserve PL(i): PL(i) = 100
i = i + 1: ReDim _Preserve OName(i): OName(i) = "XOR"
ReDim _Preserve PL(i): PL(i) = 110
i = i + 1: ReDim _Preserve OName(i): OName(i) = "EQV"
ReDim _Preserve PL(i): PL(i) = 120
i = i + 1: ReDim _Preserve OName(i): OName(i) = "IMP"
ReDim _Preserve PL(i): PL(i) = 130
End Sub
From my math evaluator, which is used internally in QB64 to calculate various values for use with CONST. This gives you the listing of what our extended Order of Operations is, from first to last.