• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Calculation by string
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calculation by string


  • Subject: Re: Calculation by string
  • From: Greg Hulands <email@hidden>
  • Date: Sat, 17 May 2003 19:01:19 +1000

Just parse the string however you see fit.
eg.

string = @"x * y";

char1 = [string characterAtIndex:0];

if (char1 == 'x')
return x * y;

You maybe be best looking at using an NSScanner instead, just read the class description and see if it is for you.

HTH,
Greg

On Saturday, May 17, 2003, at 06:37 PM, Lorenzo wrote:

Hi,
I read a string from a file.
This string contains:
@"x * y"

I already have two global int variables called "x" and "y".

Now I would like to get the product of x and y.
How should I do?


Best Regards
--
Lorenzo
email: email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Calculation by string (From: Lorenzo <email@hidden>)

  • Prev by Date: Calculation by string
  • Next by Date: Apple's and Sleepycat's BSD DataBase
  • Previous by thread: Calculation by string
  • Next by thread: Re: Calculation by string
  • Index(es):
    • Date
    • Thread