Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

moonman239

Cancelled
Original poster
Mar 27, 2009
1,541
32
Maybe the title was badly worded, but you'll understand what I mean after I explain what I want to do.

I want to make a script that creates multiple random, unique ID's. To accomplish this, I could do something like this:

Code:
on randomID()
--ID generation code
end randomID
set theid to randomID()

but I thought I could do something like this:

Code:
to randomID
--ID generation code
end randomID
set theID to randomID

Notice the lack of parentheses after "set theID to".

Somebody on a different forum was able to construct a method that would return a string with something in the string replaced with the value of another string. Here's his code:

Code:
to switchText from t to r instead of s
	set d to text item delimiters
	set text item delimiters to s
	set t to t's text items
	set text item delimiters to r
	tell t to set t to item 1 & ({""} & rest)
	set text item delimiters to d
	t
end switchText

When I tried the second block of code, AppleScript told me it expected something to follow "to randomID".

Any help would be greatly appreciated!
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.