Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6849459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:59:37+00:00 2026-05-27T00:59:37+00:00

I’m doing some parsing work, too complex to get into details, but there’s one

  • 0

I’m doing some parsing work, too complex to get into details, but there’s one simple thing I need to do (at least simple concept, maybe not simple answer). I might have a formula in a string such as the samples below. I need a function that will take a loosly-formatted formula string, parse it out, and calculate the result.

Sample:

(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 are to be ignored
  • PEMDAS method must entirely apply
  • Result shall be always a rounded Integer
  • No variables will exist, already converted to numbers
  • Decimal numbers might be part of the input

The existing parsing I already have working just gets one of these formula strings – but from there, I have no clue how to perform the actual calculations. What I’m doing specifically is doing a little line deliminated scripter to draw to a canvas, here’s some sample 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

All that already works, but now I want to say for example…

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

So the 500 - @W I already convert it to 500 - 50 but now I need to send the string 500 - 50 into this function to get the result 450.

EDIT: Solved

I’m using the parser10 as recommended, and it works perfectly for what I need to do. Here’s a sample snippet of my script code:

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)

Anything starting with an @ is a variable, which I do a StringReplace() to convert all those based on what was declared in the Var section.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:59:38+00:00Added an answer on May 27, 2026 at 12:59 am

    Parser10, written originally by Renate Schaaf for Delphi 1 and later upgraded to Delphi2 and 3 by Alin Flaider and Stefan Hoffmeister, is a fairly simple math parser. It will do the job for simple expressions and can serve as a boilerplate for more complex work.

    It is not built for speed though.

    Update :

    Hallvard Vassbotn made an update of Parser10 and added some documentation. Load it from here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am doing a simple coin flipping experiment for class that involves flipping a
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm making a simple page using Google Maps API 3. My first. One marker
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.