Results 1 to 2 of 2

Thread: Executing a string !!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Location
    Lost
    Posts
    216

    Exclamation

    Executing a string !!
    How can i execute an equation passed as a string??
    For ex: if i have
    x=2 (integer)
    "y = 2 * x + 1" (string)

    how can i obtain 5 as result ???????????????????

    Thanks...

  2. #2
    Hyperactive Member mikef's Avatar
    Join Date
    Jun 2000
    Location
    Beach bound...
    Posts
    510
    It will not execute the string. You must write the code to do the math.

    You have this:

    x = 2 <-- integer

    "y = 2 * x + 1" <-- string

    But you must also have code to solve the problem. An advanced calculator may be what you need. I used a TI-85 in high school and college. That would be easier than writing the code to extract the variables from the string and then performing the math to solve for x.

    ...later

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width