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

moonman239

Cancelled
Original poster
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:
When defining and calling handlers, you must include its parameters, even if there aren't any (in that case, you include a pair of empty parentheses after the handler name). The second form just uses labeled parameters instead of positional ones - see the Handler Basics section of the AppleScript Language Guide.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.