I deal with analysis, too complex to go into details, but there is one simple thing that I need to do (at least a simple concept, maybe not a simple answer). I could have a formula in a line such as the patterns below. I need a function that will take a lowercase form, formatted and calculating the result.
Example:
(10 / 2)+(10/30)
5+(10/30)
5+3
8
Or:
(12.5 - (0.5 * 5)) / 2
(12.5 - 2.5) / 2
10 / 2
5
Rules:
- Spaces should be ignored
- PEMDAS method should be fully applied
- The result will always be rounded Integer
- No variables will exist already converted to numbers
- Decimal numbers may be part of the input
, , , , . , , , script:
Var W 50
Var H 50
Pen Style Clear
Pen Color $000000
Pen Width 3
Brush Style Solid
Brush Color {FORM_COLOR}
Rect 0 0 {WIDTH} {HEIGHT}
Brush Color $501010
Ellipse @W @H 450 450
Brush Color $602020
Ellipse 100 100 400 400
Brush Color $703030
Ellipse 150 150 350 350
Brush Color $804040
Ellipse 200 200 300 300
EllipseG 200 200 300 300 6 2
Pen Style Solid
Pen Width 2
Pen Color {FONT_COLOR}
MoveTo 0 0
LineTo 500 500
MoveTo 0 500
LineTo 500 0
, , , ...
Var W
Var H
Set W 50
Set H 50
Brush Color $602020
Ellipse(@W, @H, 500 - @W, 500 - @H
Set W 100
Set H 100
Brush Color $703030
Ellipse(@W, @H, 500 - @W, 500 - @H
Set W 150
Set H 150
Brush Color $804040
Ellipse(@W, @H, 500 - @W, 500 - @H
, 500 - @W 500 - 50, 500 - 50 , 450.
:
parser10, , , . script:
Var S 4
Var D @S
Var L 0
Var T 0
Var R {WIDTH}
Var B {HEIGHT}
Pen Style Clear
Pen Color $00000000
Pen Width 3
Brush Style Solid
Brush Color {FORM_COLOR}
Rect 0 0 {WIDTH} {HEIGHT}
Set D @D+@S
Brush Color $00400000
Ellipse @L+@D @T+@D @R-(@D*2) @B-(@D*2)
Set D @D+@S
Brush Color $00501010
Ellipse @L+@D @T+@D @R-(@D*2) @B-(@D*2)
Set D @D+@S
Brush Color $00602020
Ellipse @L+@D @T+@D @R-(@D*2) @B-(@D*2)
Set D @D+@S
Brush Color $00703030
Ellipse @L+@D @T+@D @R-(@D*2) @B-(@D*2)
Set D @D+@S
Brush Color $00804040
Ellipse @L+@D @T+@D @R-(@D*2) @B-(@D*2)
Set D @D+@S
Brush Color $00905050
Ellipse @L+@D @T+@D @R-(@D*2) @B-(@D*2)
Set D @D+@S
Brush Color $00FB6060
Ellipse @L+@D @T+@D @R-(@D*2) @B-(@D*2)
, @, , StringReplace(), , Var.