Applescript equivalent of PHP $$ variable

Hi, i hope someone can help with this.
I'm new to mac developing and am trying to write a simple mac app to output some serial commands. This is all working fine but the software i'm using to output the serial commands works on applescript, hence using it over a purely Cocoa application.
Anyway, i have a series of buttons called statusButton1 to statusButton 12 say, and i want to turn them green (from grey) when they are clicked. I can do that by the command
statusButton1's setImage_(greenLightImage)
Where greenLightImage is the variable of the green button image.
What I am trying to avoid is a pile of if statements to turn the correct button green and the others off depending on which button is pressed. I am currently calling a function passing the number of the button pressed.
What i would like to do is something like...
statusButton(passedVariable) setImage_(greenLightImage)
I've done a lot of PHP programming before and in that language i would do something like
$temp = "statusButton" . $passedVariable
$$temp... (whatever command to change image)
I have tried many things and can't find an equivalent. Is there such a thing, or is there a better way (sure there is)
Thanks

AppleScript doesn't have a lot of language features such as pointers or variable variables, but when you have several items that you deal with often, usually you can put them into a list (or record) and then index into or loop through the items, for example:
# a property or top level variable containing all of the buttons
set buttonList to {statusButton1, statusButton2, statusButton3, statusButton4}
on doButton:sender # handle button press
  repeat with aButton in buttonList
    (aButton's setImage:greyImage) # unset
  end repeat
  sender's setImage:greenLightImage # reset
  # whatever
end doButton:
Edit to add:
Cocoa also has several classes that provide methods for managing arrays (lists) and dictionaries (records), as well as some controller classes for various object collections.

Similar Messages

  • Applescript equivalent of Automator's "Combine PDF"?

    Folks -
    I'm starting to learn Applescript, and working to use it to help automate some workflows in a prepress department.
    I'm trying to write a script that (among other things) will combine a folder full of PDFs into one file before passing it along to the next step. This is easy using Automator, but the only Applescript equivalent that I've found calls for Acrobat to launch and combine the files - this seems to run more slowly than the Automator version, which doesn't appear to call Acrobat at all. I thought I'd try scripting Preview to do the same thing, but I didn't realize that Preview isn't scriptable.
    Is there a way I can accomplish this without combining Automator and Applescript, or am I out of luck? (I have a sneaking suspicion that this may involve a shell script, which would mean that I'm out of my depth.)
    Thanks for any ides on this one..
    -Andy Gill

    Hi Andy,
    I thought I'd try scripting Preview to do the same thing, but I didn't realize that Preview isn't scriptable.
    Using [GUI Scripting|http://www.macosxautomation.com/applescript/uiscripting/index.html], it should be relatively easy to write a script that will do what you are asking for. The drawback, however, is that such a script would have to open Preview.app and so could not run inconspicuously in the background.
    Maybe you might want to have a look at these two Mac OS X Hints articles:
    [10.5: Use Preview to merge or create multi-page PDFs|http://www.macosxhints.com/article.php?story=20071114191806624]
    [10.6: Combining documents in Snow Leopard's Preview|http://www.macosxhints.com/article.php?story=20090915223224601]
    Hope it can help.

  • Autocomplete Declared PHP Variables in Dreamweaver

    Is there a way to autocomplete php variables that have been
    declared? For instance, whenever you type $ in a PHP code block, a
    pop up list would automatically come up with all the variables you
    have already declared. This would GREATLY speed up coding and help
    to insure coding accuracy.
    If there is a way to do this now, could someone please clue
    me in? I've searched and searched forums, help files, and google.
    If this is not available, where should I go to request this
    feature?
    Shanna

    jsteinmann wrote:
    > With asp.net missing, along with several other things
    discontinued, dreamweaver will have to cater to php developers in
    these kinds of ways.
    If you want Dreamweaver to add features posting this sort of
    comment in
    a user-to-user forum won't have the slightest impact on the
    direction
    that Dreamweaver actually takes. You need to make your views
    known by
    submitting feature requests through the official channel:
    http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform
    Submitting requests doesn't guarantee that your ideas will be
    adopted in
    the next version or even the one after that, but it does get
    them on the
    development team's radar.
    David Powers, Adobe Community Expert
    Author, "The Essential Guide to Dreamweaver CS3" (friends of
    ED)
    Author, "PHP Solutions" (friends of ED)
    http://foundationphp.com/

  • XSL and a php variable

    I am looking for a solution to a problem I am having with an
    XSL stylesheet and trying to use a php variable. The page I am
    working on is a page to display some information based on the
    graduation year of a class (I work at a school). For example last
    years graduating class of 2006.
    I have a statement in the XSL sheet that limits the shown
    data to only that class year
    <xsl:for-each
    select="school[class_of=&apos;2006&apos;]">
    I would like to replace that 2006 above with a php statment
    such as $classyear since on that page the data is to display the
    variable is already present, but I cannot get it to work. I have
    tried to place php in the XSL and also to change the extention etc
    and they all produce errors. I am assuming that XSL just can't use
    variables in it?
    Any help would be greatly appreciated. I would hate to have
    to duplicate that one XSL sheet for every class year.
    thanks
    chris

    David,
    thank you so much so far for you help, it does sounds like we
    are talking about the same thing. I think I am getting close.
    I do want to pass the value when the XSL sheet is embedded.
    I tried that and it seemed to not work, says the variable is
    not found (I am using the dreamweaver built in transform).
    I am just getting into the more complex XML stuff so I
    apologize for my lack of knowledege.
    I have pasted some of the code below, any idea what I am
    doing wrong?
    the page where it is embedded is
    http://www.nmhschool.org/news/test11.php
    php doc with the embed and include
    <?php
    $mm_xsl = new MM_XSLTransform();
    $mm_xsl->setXML("test11.xml");
    $mm_xsl->setXSL("test11.xsl");
    $mm_xsl->addParameter("yearXX", "2006");
    echo $mm_xsl->Transform();
    ?>
    http://www.nmhschool.org/news/test11.xsl
    is the XSL
    <xsl:for-each
    select="Report/GroupHeader2/GroupHeader2_1[q1.CnPrAl_Class_of =
    $yearXX]">
    <table width="100%" border="1" cellspacing="1"
    cellpadding="1">
    <tr> blah blah blah........
    http://www.nmhschool.org/news/test11.xml
    is the XML data

  • PHP variable scope bug in CT

    I have a page where I declare PHP variables which are then
    used inside an include file.
    When I try to edit the page in Contribute, I get a notice of
    "Variable undefined" in the include.
    This do work in Dreamweaver and it did work in Contribute in
    other projetcs I have done.
    Any suggestions?

    Hi Dont know if your still getting notifications on this but...
    Did you ever find an answer as I am having the same issue.
    I have tracked down why its not working but don't know how to stop it.
    In Dreamweaver it keeps the php include reference as code when it saves the file, where as Contribute seems to process the include and dump the output back to the page.
    This means that any common includes like headers and footers are no-longer included dynamically when the page loads as Contribute has embeded them when it created the page.
    This alsos mean if you have included a php file with common functions that you may use on your site this will never appear and any variables you declare wont exist.
    How rubbish is that!?
    If anyone can help with this issue it will be greatly appreciated.
    I'm hoping there is some simple Contribute comment I can put in to say "dont process this code - leave it alone!"
    Thanks

  • PHP Variable Capitalize

    Okay so I have a php variable, and I set it to "Home", then when I call it though I get a result of "home". How do I make the variable retain the capital H?

    MurraySummers wrote:
    No - actually we were both incorrect. The only condition is "isset($_GET['page']", and if true, the first option is executed and a lower-case value is returned; if false, the second.
    I think that's wrong. If the first condition was being executed then the OP would have the result "Home" returned NOT "home"
    He/She has obvioulsy got a link set up like .php?$foo=Home
    As the first condition IS met as you say and is correct the second condition is executed (met) as I say, the third is only returned if 1 and 2 are not met.
    Oh ok I see what your saying. Cross wires AGAIN we both agree that the ?> is being met
    I think half this stuff is a battle with the correct terminology aint it lol
    So this is being met:
    $page = (isset($_GET['page'])
    This is being return as the above is met
    ? strtolower($_GET['page'])
    This never gets a look in
    : 'Home');
    If you view the conditions as ? strtolower($_GET['page']) : 'Home');
    Then youre right I'm wrong.
    This is not a condition which I was taking into consideration.
    $page = (isset($_GET['page'])

  • Accessing PHP variables (especially _SESSION)

    Hi,
    since CaioToOn! suggested here that I should use $_SESSION and I need to do this anyway, I spent the last 1+ hours trying to figure out how to do that. Sadly, I could not really figure it out except that there seems to be an issue with the session ID and that it has to be passed along to the swf file.
    Can somebody please tell me how to read/write from/to PHP variables (not $_GET)?
    P.S.: Here a simple example code (test.php and then the testintro.fla AS code):
    <? session_start();
    $_SESSION["intro"] = 0;     // has the intro been played?
    ...     // code for including the swf
    ?>
    if(intro == 0)
         myclip.gotoAndPlay(2);   // play intro
         intro = 1;
    else
    { myclip.gotoAndPlay(24); }     // skip the intro and go straight to the end

    none of those reasons would require php to embed a swf.
    normally, with flash, you could use a session variable to pass data from html to the swf.  you set your session variable's data with a html form or something similar and then use flashvars to pass that info to your embedded swf(s).
    you can also pass html data to an embedded swf using javascript and the externalinterface class.

  • Is there a PHP variable that will fetch the TITLE of the file?

    I learned (thanks to David Powers) that you can use $_SERVER['PHP_SELF'] to refer to your current URL, which is useful in situations like putting a "Share on Facebook" button on your page.
    However, some of these social networking sites allow you to also put the Article Title in the same button, so I was wondering if there was a PHP variable I can use for *that*. This way, by specifying the title of the article in the aptly-named title tag of the page, I can put those "submit this page to" links as includes that don't need to be specifically-edited for each page.

    Create a variable for the title and use it in both places.
    <?php
    $title = 'Things you always wanted to know about...';
    ?>
    <title><?php echo $title; ?></title>
    // later on
    <?php echo $title; ?>
    Alternatively, if your page content is generated dynamically, you can store the title in the database.
    Another technique would be to base the title on the page name.
    $page = basename($_SERVER['SCRIPT_FILENAME'], '.php');
    $title = ucwords(str_replace('_', ' ', $page));
    That would store "About Us" in $title if the page is called about_us.php.

  • Applescript equivalent to VBA XMLHTTP object?

    Having no luck after hours of research on this. Is there an Applescript equivalent to the VBA XMLHTTP object?
    We have an Excel form that can pass data to a web service. We basically take the XML, wrap it in a SOAP envelope and send it using the xmlhttp object. Unfortunately, the xmlhttp object does not appear to exist for the mac version of Excel. If there is no equivalent to the xmlhttp object, is there an alternate way of making this work in applescript?
    Thanks in advance

    Thanks guys. We were able to solve the problem through Query Tables in VBA rather than resorting to Applescript.
    For anyone interested in the solution:
    Sub URLGetQuery()
    With ActiveSheet.QueryTables.Add(Connection:= _
    "URL;http://mywebservice.com/mywebserviceproc",
    Destination:=Range("a1"))
    .PostText = SoapString
    .BackgroundQuery = True
    .TablesOnlyFromHTML = True
    .Refresh BackgroundQuery:=False
    .SaveData = True
    End With
    End Sub
    Lets you post to a web service without using the xmlhttp object
    Message was edited by: Kennedy27

  • Equivalent of PHP's print_r(), var_dump(), or var

    Does anyone know the Java equivalent of PHP's print_r(), var_dump(), or var_export()?
    I just started with Java a few days ago and I'm having a really tough time debugging stuff.
    Thanks!

    You might want to read: http://today.java.net/today/2004/05/05/HardcoreJava.pdf
    This is a chapter from O'Reilly's Hardcore Java (http://www.oreilly.com/catalog/hardcorejv/) Review of book here: http://www.jaxmagazine.com/itr/buchtipps/psecom,id,283,nodeid,148.html
    I have only briefed through it (I am also coming from php and looking for the same answer that you are), and there is some sort of generic toString-method that will print out more or less var_dump()-like strings.
    I gave up this way as I did not want to buy the mentioned book, and believe there is a simpler solution out there.
    I have found JOI - Java Object Inspector (http://www.programmers-friend.org/JOI/), which I am about to start using, hoping it will be helpful although clumsy as it cannot be used in logs etc.
    The optimal would of course be a function String varToString(Object object) that used reflection-methods to output detailed information about object's insides, although I have not found any. I am building a lite version myself at this moment, being able to output at least strings and nested arrays.
    I believe somebody have written something similar? Please share, if so!

  • Search/Replace for/with php variable name

    Hi all.
    I have just updated from Dreamweaver 5 to 5.5 and now I am missing a very handy functionality.
    What I want to do is to replace all occurences of $a with $b.
    In Dreamweaver 5 that was very easy by using "Find and replace":
    Find in: All open documents
    Search: Sourcecode
    Find: $a
    Replace: $b
    Active options: Match case and Match whole word !!!!
    Now in Dreamweaver 5.5 the option "Match whole word" is automatically disabled as soon as I enter a $ (dollar) in the search field.
    I assume this has something to do with regular expressions but I do NOT check the option "Regular expression" in the search and replace dialog.
    Is this a bug?
    What are my options now.
    If I don't have the possibility to to tick "Match whole word" my search does also replace all occurrences of $abc and $answer etc. with $b.
    Thank you for your help

    samet2011 wrote:
    I have Dreamweaver 5 and 5.5 running parallel on my computer.
    I can confirm that the way I described and used to use is working on Dreamweaver 5.
    I was the person who informed Murray that Dreamweaver CS5 and CS5.5 both behave the same way. I have just checked as far back as CS3, and it also disables "Match whole word" when you enter a dollar sign in the Find field of the Find and Replace dialog box. In fact, that option is disabled whenever you enter any nonalphanumeric character (except an underscore) in that field. It's not limited to dollar signs.
    Why it's not disabled in your version of CS5 is a mystery.
    However, to solve your problem, you don't need either a regex or "Match whole word". Simply type the name of your PHP variable followed by a space into the Find field. Also add a space after the name of the variable you're using as the replacement.
    What "Match whole word" does under the hood is to use a regular expression to find a word break. As long as you leave a space between your variables and any following code, simply adding the space to your search will do the trick.
    However, if you have cases where a variable is followed by a comma, closing parenthesis, or some other character, you will need to use the following regex:
    Find: \$variable_name\b
    Replace: $new_name
    The \$ looks for a dollar sign. The variable_name matches the literal text of the variable name (replace it with the actual text you're looking for). The \b matches a word break in exactly the same way as "Match whole word".
    In the Replace field, $new_name is the literal name of the new variable.

  • PHP Variables unloading

    I have a lot of included files in my site. At the end of each
    included file,
    I close the sql, but would also like to close the variables
    used to produce
    the HTML.
    I'm having a hard time with my searching getting some
    relevant results. Can
    somebody help me here on what I"m looking for?
    TIA,
    Jon Parkhurst
    PriivaWeb
    http://priiva.net.

    On Thu 24 Aug 2006 04:36:46p, crash wrote in
    macromedia.dreamweaver.appdev:
    > I have a lot of included files in my site. At the end of
    each included
    > file, I close the sql, but would also like to close the
    variables used
    > to produce the HTML.
    >
    > I'm having a hard time with my searching getting some
    relevant
    > results. Can somebody help me here on what I"m looking
    for?
    I'm not sure I follow you here. Are you saying that you want
    to limit
    the scope of the PHP variables to the included file, so that
    in something
    like this:
    <?php
    include_once('fileA.inc');
    include_once('fileB.inc');
    include_once('fileC.inc');
    ?>
    you can have a variable, say $crashsVariable, in fileA.inc,
    fileB.inc and
    fileC.inc, and have it take on a separate value in each of
    them, but not
    affect any of the others?
    Without doing any experimentation... Using the
    include_once()s makes the
    include files, and thus all their code, part of the larger
    code block.
    AFAIK, the scope of a variable would be the calling file, so
    the answer
    would be no.
    The PHP docs[1] have this to say:
    The scope of a variable is the context within which it is
    defined.
    For the most part all PHP variables only have a single
    scope. This
    single scope spans included and required files as well.
    but go on to add:
    However, within user-defined functions a local function
    scope is
    introduced. Any variable used inside a function is by
    default limited
    to the local function scope.
    So if you use $crashsVariable within a function within the
    included file
    (or, for that matter, the main file), it's local in scope.
    Otherwise, a
    variable exists for the entire page.
    If you've spent the include file building a long string of
    text, which is
    eventually output as HTML:
    <?php
    $myvar = "<head>\n";
    $myvar .= "<title>$myDynamicTitle</title>\n";
    echo $myvar;
    ?>
    the only way I know would be to do something like
    $myvar = '';
    Hopefully David Powers or somebody who actually knows might
    check in.
    [1]
    http://www.php.net/variables.scope

  • Javascript change property of PHP variable according to date in list menu selection

    I'm creating a booking form which selects prices and dates from a Mysql databse according to the code transported in the URL.
    I have successfully got the form to display dates for this year and next year in a drop down menu/list form item.
    However, I would like to change the price according to what year the selected date falls in.
    The key variable that needs to change is this $coursefee
    If a date in 2009 date (e.g. 2009-10-12) is selected the varibiable $coursefee would change to be
    <?php $coursefee=$row_rs_course['price09'];?>
    And if a date like 2010-10-12 is selected the varibiable $coursefee would change to be
    <?php $coursefee=$row_rs_course['price10'];?>
    To complicate matters the menu is dyamically populated too:
    <select name="dates" class="course" id="dates">
    <?php
    do { 
    ?>
    <?php
    $date1 = strftime("%d %b",strtotime($row_rs_dates['start_date']));                       
    $date2 = strftime("%d %b %Y",strtotime($row_rs_dates['finish-date']));
    ?>
    <option value="<?php echo($date1." - ".$date2); ?>"><?php echo($date1." - ".$date2);?></option>
    } while ($row_rs_dates = mysql_fetch_assoc($rs_dates));
      $rows = mysql_num_rows($rs_dates);
    if($rows > 0) {
    mysql_data_seek($rs_dates, 0);
    $row_rs_dates = mysql_fetch_assoc($rs_dates);
    </select>
    I'm pretty sure the answer lies in the murky world of javascript but unfortunately I haven't the first clue about javascript.
    Can anyone help me with this?
    Cheers
    Dave

    Thanks David,
    I can see that would work and I'd have no problems doing that but wouldn't that mean that all the oher data the user had fillled in would dissapear?
    There are too many fields I think to transfer everything in the URL and the date selection field is way down the form and I think it would seem pretty odd to have it before name address etc. That's why I thought a javascript solution would be more suitable as it needn't rely on a page refresh.
    Cheers
    Dave

  • AC_FL_RunContent and php variable from recordset

    Hi, can anybody point me to a resource on how to grab the
    name of the .swf file from my db and pass it to the active content
    javascript?
    If I just replace the the movie name with a php echo that
    grabs the file name from the db there is no playback.
    TIA
    -Frank

    Should work fine.
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "ronin701" <[email protected]> wrote in
    message
    news:gb9gll$lck$[email protected]..
    > I'll have to strip the extension after I pull it out of
    the record set,
    > assign
    > that value to a variable and echo that in the js where
    there is no
    > extension
    > and use the standard echo in the areas where it need the
    extension, very
    > good,
    > thanks for pointing me in the right direction.
    >
    > -Frank
    >
    http://www.roninwerks.com
    >

  • Parsing php variable to jnlp

    Im having trouble using $_GET[id]
    my script opens an iframe at <iframe src=\"http://****.com.au/uploader/fileuploader/fileuploader_jnlp.php?id=".$_SESSION[user_id]."\" width=0 height=0 name=\"internal\"></iframe>";
    my jnlp file looks like:
    <?php header('Content-type: application/x-java-jnlp-file'); ?>
    <jnlp spec="1.0+" codebase="http://www.****.com.au/uploader/fileuploader" href="fileuploader_jnlp.php">
    <information>
    <title>Uploader</title>
    <vendor>Me</vendor>
    <homepage href="index.html" />
    <description></description>
    </information>
    <resources>
    <j2se version="1.4"/>
    <jar href="fileuploader.jar" main="true" />
    <jar href="JimiProClasses.jar" />
    </resources>
    <application-desc main-class="fileuploader.FileUploader">
    <argument>http://www.****.com.au/uploader/fileuploader/upload.php</argument>
    <argument><?php echo $_GET[id]; ?>/</argument>
    <!-- <argument>100000</argument> -->
    <!-- <argument>thomas:test</argument> -->
    </application>
    <security>
    <all-permissions/>
    </security>
    </jnlp>
    but its not parsing the variable
    I have tested for the variable using
    <?php
    echo $_GET[id];
    ?> on a standard php script and all works fine
    I can even hard code the variable and it works
    <?php header('Content-type: application/x-java-jnlp-file'); ?>
    <?php $bob =367; ?>
    <jnlp spec="1.0+" codebase="http://www.****.com.au/uploader/fileuploader" href="fileuploader_jnlp.php">
    <information>
    <title>Uploader</title>
    <vendor>Me</vendor>
    <homepage href="index.html" />
    <description></description>
    </information>
    <resources>
    <j2se version="1.4"/>
    <jar href="fileuploader.jar" main="true" />
    <jar href="JimiProClasses.jar" />
    </resources>
    <application-desc main-class="fileuploader.FileUploader">
    <argument>http://www.****.com.au/uploader/fileuploader/upload.php</argument>
    <argument><?php echo $bob; ?>/</argument>
    <!-- <argument>100000</argument> -->
    <!-- <argument>thomas:test</argument> -->
    </application>
    <security>
    <all-permissions/>
    </security>
    </jnlp>
    Can someone please tell me where I am going wrong

    hi,
    I'm gonna have to do exactly the same thing as you...
    I haven't look at it yet, but I'd apreciate if you publish the working PHP script you fixed (if you managed that is ;-)).
    thanx a lot.
    Patrice.

Maybe you are looking for

  • Photoshop CC keeps crashing

    Everytime I try and use the save as funtion. Please help. I am running it on a 27-inch iMac with a 2.7GHz Intel Core i5 proccessor with 16 GB of ram. Here is the crash report. Process:         Adobe Photoshop CC [1521] Path:            /Applications/

  • Bridge CS6 Output with PDFs

    I had a  request from a client about some items we have done in the past for their company (wearable items).  There is no easy way for me to create a list.  So... I went to my wholesaler site to pull down copies of invoices that showed the items we h

  • Any idea why images in pdf files turn into negatives?

    I have noticed that anything saved in a pdf format, shows up as a negative on the ipad. Pictures and colours used in headers, etc. Very strange. Have noticed this in Goodreader as well as in email. Thanks.

  • ITunes v7.0.2 - installs but won't set up

    Hey guys, I seem to have the same problem some other people on here have, I've just had a newer ipod that requires latest ITunes, it downloads, it installs, and then it just sits there and none of the files will respond to anything further, and it wo

  • JMS with old JVM

              I apologize for lack of research before posting the question, but a direct answer           would save a lot of time...           Could a JMS client service that would post and consume messages from Weblogic be           implemented using J