Re: How to calculate/process this one?
Re: How to calculate/process this one?
- Subject: Re: How to calculate/process this one?
- From: Jean-Baptiste Le Stang <email@hidden>
- Date: Sat, 27 Apr 2002 15:44:14 +0200
>
Hi,
>
>
I have a problem thinking of a routine which does the following:
>
>
Let's say I have a random number like 11050. Now I want to add each pair
>
of consecutive digits to give the next line (so 11050 becomes 2155). I
>
want to repeat this step until I have a two-digit number.
>
>
I tried over and over again but did not find a solution for this problem.
>
>
Anybody out there who could help me?
>
>
With very kind regards,
>
>
Martin
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.
Try the following
set mynum to 11050 as string
set newnum to ""
repeat with x from 1 to (count mynum) - 1
set newnum to newnum & (((item x) of mynum) + ((item (x + 1)) of mynum)
as string)
end repeat
repeat until (newnum as integer < 100)
set mynum to newnum
set newnum to ""
repeat with x from 1 to (count mynum) - 1
set newnum to newnum & (((item x) of mynum) + ((item (x + 1)) of
mynum) as string)
end repeat
end repeat
JB Le Stang
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.