Re: strcat in applescript?
Re: strcat in applescript?
- Subject: Re: strcat in applescript?
- From: kai <email@hidden>
- Date: Fri, 12 Nov 2004 23:53:19 +0000
Forgive me for adding a couple of late points here...
On Thu, 11 Nov 2004 10:36:17 -0800, Miss Augustina wrote:
on intToStrcat (char a, int b)
return [ how do i return a + b without adding them? ]
end intToStrcat
so if a = X and b = 2, it should return "X2" as a string.
The result of using the concatenation operator (&) in AppleScript will
depend on the class of the left hand operand. If it's a string, then
AppleScript will try to coerce the value of the other (non-string)
operands to strings:
"A" & 2
--> "A2"
Incidentally, this will not be the case if the items are reversed - and
the left hand operand is an integer:
2 & "A"
--> {2, "A"}
To produce a string result here, we could first coerce the left hand
operand to a string:
(2 as string) & "A"
--> "2A"
(Of course, if both/all operands are already strings, then
concatenation is even simpler.)
"A" & "2"
--> "A2"
also when passing values to functions in AppleScript, the syntax
"value" is used. If i want to substitue a return value for a function
do I also need to concatenate quotes around my return value? so if i
wanted to use the above function in place of specifying a static value
basically, would Applescript recognize the return value without quotes
or do I need to concatenate them around the return value?
set rowID to "2"
set colID to "A"
set x to Value of Cell intToStrcat(colID, rowID) <-- will return A2
not "A2".
sorry if these are totally obvious questions.. feel free to point me
to a reference if that is more appropriate.
I get the impression that you're trying some of this within an
application (Microsoft Excel?) tell block. If that's the case, and you
need to call a subroutine from within the tell statement, you'll need
to use the words 'of me' or 'my', to indicate that the subroutine is
part of the script (and not a command for the target of the tell
statement). So perhaps you might try something like this:
------------------------
on intToStrcat(str, int)
str & int
end intToStrcat
set rowID to 2
set colID to "A"
tell application "Microsoft Excel"
set x to value of cell (my intToStrcat(colID, rowID))
end tell
------------------------
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden