Re: Addressing variables in subroutines
Re: Addressing variables in subroutines
- Subject: Re: Addressing variables in subroutines
- From: Matthew Smith <email@hidden>
- Date: Sat, 22 Feb 2003 09:34:49 +1100
on 21/02/2003 03:27, Jan Bruners at email@hidden wrote:
>
I am trying to write a script using a subroutine like this:
>
>
>
on zaehle(var1,var2)
>
tell application "FileMaker Pro"
>
show every record of database "scheine.fp5"
>
show (every record whose cell "ES_Note" is string1)
>
set string2 to count of records
>
end tell
>
end zaehle
>
>
zaehle(note1,sg1)
>
-- snip
>
>
The subroutine obviously uses the current value of the variables, which is ok
>
for var1. But var2 should be treated as the variable's name (to modify the
>
variable's value in the subroutine), not as var2's value.
>
>
I already defined both vars as global.
It's a bit confusing when your example does not even use var1 and var2. I am
assuming string1 and string2 are meant to be var1 and var2. Parameters are
passed as values.
If you have already defined var1 and var2 as globals then you are reusing
those names for parameter variables. You have global variables and parameter
variables with the same name. Your globals are not reachable. For it to work
you would have to removed the parameters from the handlers definition and
set the globals before calling the handler..
For your example, a better way would be to return a value. Handlers are more
like functions than subroutines.
on zaehle(var1,var2)
tell application "FileMaker Pro"
show every record of database "scheine.fp5"
show (every record whose cell "ES_Note" is var1)
return count of records
end tell
end zaehle
set recCount to zaehle(note1)
--
Matthew Smith
_______________________________________________
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.