• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Coerce String to Handler?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coerce String to Handler?


  • Subject: Re: Coerce String to Handler?
  • From: Timothy Bates <email@hidden>
  • Date: Tue, 17 Apr 2001 14:35:44 +1000

On 17/04/2001 7:30 AM, "Chris Nebel" <email@hidden> wrote:
> You can bind any known-in-advance handler to a variable, but you
> can't do it based on an arbitrary string.

This is handled very smoothly in PHP (he said, hoping not to invoke the
NIMBY syndrome).

I used it the other day in a cgi which receives a variable number of inputs,
each referring to a new student. I needed to be able to say. I could grab
the studentID as "ID#" and then I wanted to say:

set <gradeTotalID#> to <grade1ID#> + <grade2ID#>

before uploading the grade into MySQL.

In php, it was easy to turning these arbitrary strings into variable names
(the variables already existed of course, passed in by php, I just need to
be able to refer to them on the fly).

I just said:

$thisGrade1 = "grade1" . ID# ;
echo($$thisGrade1);
--> grade 1 for student with ID #

or in applescript syntax

set grade1 to "grade1" & ID#
get $grade1

(where adding the "$" in front of the variable means "I want you to use the
contents of this variable as a variable"

works a charm.

I am just about to submit this functionality as a request for an applescript
enhancement and hope that others who are also wanting to turn AppleScript
into a great embedded language for driving the internet will follow suit.

tim


References: 
 >Re: Coerce String to Handler? (From: Chris Nebel <email@hidden>)

  • Prev by Date: Re: CGI?
  • Next by Date: Re: Coerce String to Handler?
  • Previous by thread: Re: Coerce String to Handler?
  • Next by thread: Re: Coerce String to Handler?
  • Index(es):
    • Date
    • Thread