Setting variables from path

How can I set the name of a value from an alias such as
"P & M:Editorial Photography:THISFOLDER:fpo:Book Shelf:"
to
"THISFOLDER"
Basically I want to set the name of a value to whatever the name of the second level folder up from the given path is.
Pedro

on script_title()
Filename : ExtractDirNameFromPath.scp.as
Pathame : ExtractDirNameFromPath.scpt (Script Debugger)
Author : Bill Hernandez
Version : 1.0.0
Updated : Friday, December 15, 2006 ( 12:18 AM )
end script_title
-- ---------+---------+---------+---------+---------+---------+---------+---------+ ---------+---------
on script_notes()
How can I set the name of a value from an alias such as
"P & M:Editorial Photography:THISFOLDER:fpo:Book Shelf:"
to
"THISFOLDER"
Basically I want to set the name of a value to whatever the name of the
second level folder up from the given path is.
Pedro
end script_notes
-- ---------+---------+---------+---------+---------+---------+---------+---------+ ---------+---------
property NoOfLevelsFromTheEnd : 2
-- ---------+---------+---------+---------+---------+---------+---------+---------+ ---------+---------
on run
tell me
set delim to ":"
set theText to "P & M:Editorial Photography:THISFOLDER:fpo:Book Shelf:"
set aList to SplitString(delim, theText)
set NoOfItems to count items in aList
set whichItem to (NoOfItems - NoOfLevelsFromTheEnd)
set myVar to (item whichItem of aList)
my ShowMsg(myVar, 5)
end tell
end run
-- ---------+---------+---------+---------+---------+---------+---------+---------+ ---------+---------
on SplitString(delim, theText)
if (the last character of theText is equal to delim) then
set theText to (characters 1 thru -2 of theText) as string
end if
set old_delims to get AppleScript's text item delimiters -- always preserve original delimiters
set AppleScript's text item delimiters to delim
set theList to text items of theText
set AppleScript's text item delimiters to old_delims -- always restore original delimiters
return theList
end SplitString
-- ---------+---------+---------+---------+---------+---------+---------+---------+ ---------+---------
on join(theList, delim)
set old_delims to AppleScript's text item delimiters -- always preserve original delimiters
set AppleScript's text item delimiters to delim
set theStr to theList as string
set AppleScript's text item delimiters to old_delims -- always restore original delimiters
return theStr
end join
-- ---------+---------+---------+---------+---------+---------+---------+---------+ ---------+---------
on ShowMsg(s, howLong)
tell application "Finder"
activate
if (howLong = 0) then
set theTime to 3
else
set theTime to howLong
end if
set b1 to "OK"
display dialog s buttons {b1} default button {b1} giving up after theTime
end tell
end ShowMsg
-- ---------+---------+---------+---------+---------+---------+---------

Similar Messages

  • Setting variables from a testcase?

    Hello,
    How do I access variables from my BPEL flow from a testcase?
    I need to set some header variables and such that is not availible in the emulate tab so I am looking for a way to manualy in my testcase add/alter/read variables from the BPEL flow?
    I know this "could" be emulated by setting them in the normal flow but since it is test specific I would like to avoid adding thing to the flow and instead have them in my "test case".
    // MickeM

    shouldn't I also be able to access the outer classes methods? It doesn't seem to do this either.

  • Can you control format when setting variable from dashboard prompt?

    I'm setting a session variable from a calendar date prompt in a dashboard prompt, and the variable is referenced in a calculation in the business model. I'm initializing the date prompt from another variable which returns format TIMESTAMP 'YYYY-MM-DD 00:00:00', and the initial load of the dashboard is successful. After changing the value of the date prompt, the query fails because the prompt sets the variable to 'mm/dd/yyyy'.
    My question is: Is there any way to control the formatting when setting a variable from a dashboard prompt? I would like to get the timestamp format.
    Thanks,
    Greg

    If You wants time than in dashboard prompt's coloumn formula use cast function as "cast(date as time)" if date than "cast(date_col_name as date)". But I also have that one problem.Firstly tell me, Is it possible that using two dates in using betwwen operator in dashboard. We access server variable. If not working one thing more that u should have filter on date coloumn in report layout.And in action coloumn u select prompted. Than It will must work.
    Thanks
    Haroon

  • Set Variables from HTML

    Here is the set up, I have a video player embedded in an html
    file. The player will play a lead in video for branding purposes IF
    the user has not viewed this lead in video yet. ELSE it wil play
    the video they specified and then continue to play the rest of the
    videos in a que.
    Everything is fine except, the current video is dependant on
    the HTML page the view is at and I would rather just have 1 swf
    file rather than 1 swf file for every video.
    So my question is, how can i get the HTML page to tell the
    swf file which file to load after the lead in file. I essentially
    need to send this parameter from the HTML file to the swf file -
    How do I do that??
    Thanks!

    Using FlashVars is just appending the variable to the SWF's
    url. So, in your embed script, where ever you have the path to your
    SWF, like, mymovie.swf, you just append whatever variable you need
    to that. So, lets say you want to pass in a name, you would use
    mymovie.swf?name=dzedward
    Then, in flash retrieve it like so:
    root.loaderInfo.parameters.name;
    Lets say you want to pass in first and last name:
    mymovie.swf?firstName=Damon&lastName=Edwards
    retrieve it like so:
    root.loaderInfo.parameters.firstName;
    root.loaderInfo.parameters.lastName;
    Now, if you're using SWFObject to embed your SWF, its as
    simple as:
    so.addVariable("name", "dzedward");
    retrieving it the same way as above.

  • Set variable from cookie value

    Hi,
    I have a website that saves a cookie to your browser when you log in,
    The cookie value is the name of the user.
    I want to see if I can read this value in captivate and set it as a variable in the content therefore no need to re-enter details in the content.
    I have tried to tackle this using JS but my experience is limited.
    Im using Cp8.
    Thanks in advance...

    Hi VC, thanks for reply,
    //try to set the value and see if it works
    $s('P1_ID_PER_KND_NA_CRYPT','A422313E7F62D04D12347E7DE85DC53E')doesn´t work either, firebug brings up no error but i get an checksum error for this element from the apex engine, I will test the Apex internal GetCookie Function but my own function work very well too, the error is after that...
    what i see, i also get the checksum error when using the varibable id_per_knd_na, too.
    so i think, javascript tries to set the value to the hidden element, but the apex engine prvented it because of SSP.
    Any other ideas?
    ps: i use apex 4.0.2

  • Setting variables from inner class

    I have a GUI that takes users information and provides a quotation as componants are clicked. My componants' Listeners are in seperate inner classes and from these I want to add certain details to variables, it seems to compile and run but it doesn't seem to be changing the value of the variable when the componants are clicked, is there any reason why this happens, my code is below:
    public class MyGUI extends JFrame{
            public MyGUI(){
              //GUI STUFF HERE
            double Price;
         private String total=calculate();
         public String calculate(){
              double aTotal=Price;
              return "$ " + aTotal;
         class MyListener implements ItemListener{
              public void itemStateChanged(ItemEvent evt){
                   if(evt.getSource()==rad1) {
                   Price=0.10;
                   else if(evt.getSource()==rad2) {
                   Price=0.12;
                        totalLab.setText(total);
    }

    shouldn't I also be able to access the outer classes methods? It doesn't seem to do this either.

  • Set variables from recordset

    I have an SQL table that I store OrderID, ItemID, Qty.  There are 15 possible ItemID's (will never be more).  I need to output the order into a single table row that shows the orderID and the qty for each item.
    For example:
    <cfquery name="orders" datasource="xyz"
    Select *
    From solditems
    Where orderid = 'Order1"
    </query>
    Would return something like:
    Order1, Item3, 6
    Order1, Item4, 7
    Order1, Item18, 10
    The table needs to look like:
    <tr>
    <td>#orderID#</td>
    <td>#item1qty#</td>
    <td>#item2qty#</td>
    <td>#item3qty#</td>
    <td>#item4qty#</td>
    <td>#item5qty#</td>
    <td>#item6qty#</td>
    <td>#item7qty#</td>
    <td>#item8qty#</td>
    <td>#item9qty#</td>
    <td>#item10qty#</td>
    <td>#item11qty#</td>
    <td>#item12qty#</td>
    <td>#item13qty#</td>
    <td>#item14qty#</td>
    <td>#item15qty#</td>
    </tr>
    I'm at a loss trying to figure out how to match the row from the results of the record set into the right #itemXqty#.
    Hope I explained this well and thanks in advance for pointers in the right direction!
    Gary

    You could do something like
    <cfoutput><table border="1"><tr><th>#orders.orderID#</th></cfoutput>
    <cfoutput query="orders">
        <td>#itemID##qty#</td>
    </cfoutput>
    </tr></table>
    For a start, your query would be more efficient using "select orderID, itemID, qty" instead of "select *" (assuming, of course, that the table has more than the 3 columns).

  • Setting windows environment variables from Java program

    Is there any way to set environment variables from Java program in Windows? Any help is appreciated.
    Here is my situation:
    I need to decrypt an encrypted Oracle user password in a batch file which will be used while running a sql script with sqlplus. I was planning to have bat file which will call a Java program decrypt the password and set it as an env variable in windows which will be available while calling sqlplus.
    thanks

    Runtime.exec has a lot of overloadings. Two of them
    allows you to specify the environment variables.
    exec
    public Process exec(String[] cmdarray,
    String[] envp,
    File dir)
    throws IOExceptionExecutes the specified command and
    arguments in a separate process with the specified
    environment and working directory.
    cmdarray - array containing the command to call and
    its arguments.
    envp - array of strings, each element of which has
    environment variable settings in format name=value.
    dir - the working directory of the subprocess, or null
    if the subprocess should inherit the working directory
    of the current process.
    I had this sample program:
    public class SetVarExample {
    public static void main (String[] args) throws Exception {
         String[] cmd_env= new String[] {"password="+"ABCD","Path=C:\\Sun\\AppServer\\jdk\\bin"};
         String cmd = "cmd /c SET ";
         Runtime.getRuntime().exec(cmd,cmd_env);
    System.out.println( "Finish ...." );
    I tried it in a command prompt. But looks like when the program exits, it's a whole new process and so it does not retain the env variables set in the java program.
    Any suggestions? Am I doing it worng?
    thanks

  • Can I set a Session Variable from a Dashboard Prompt, using values that are

    Hi All
    Trying to set a Session Variable to an integer value, by letting users select a text value from the drop-down list on a Dashboard Prompt. The goal is to set the input parameter to the IndexCol function, but to provide the end users with a text description of what they are setting.
    Select Value Set Variable Value
    My 0
    My Team 1
    My Companies 2
    My Teams Companies 3
    Any suggestions on how to accomplish this? Certainly we could populate the drop-down from a data source, however I don't see how to populate a variable with something other than the values on the screen.
    The IndexCol function is referenced in a Filter in Answers, and I'm thinking to populate a Session variable using the (Presentation) variable value set from the prompt. But how to do this? I see a reference to a function NQSSetSessionValue(), but cannot find documentation on how it works.
    Any clue will be greatly appreciated.
    Thanks

    Hi kishore..
    Looks like the link u have sent uses advanced SQL tab to set session variables. I want to know if I can use "set variable NQ_SESSION.myvar= @something" in the "SQL results" -while creating a dashboard prompt-.
    Purpose: I want the session variable to be set based on whatever report that im currently in.
    And i dont want to use presentation variables because im using a reset button in my page.
    My reset script resets presentation variables and NOT session variables.
    Thanks in advance
    Loy

  • Dynamically Setting a Variable from a Connection String that has been set by a Config File

    Hi Guys
    I'm setting up a Master / Slave (Parent / Child) dtsx environment but I'm unable to work out how to dynamically set a variable in the Master dtsx from a connection string that has had its value set by a config file. I'm sure it's possible.
    Below is the what I'm hoping to achieve. I've set up everything apart from the highlighted section.
    Any ideas?

    First, what version of SQL Server are you using?
    You could switch the problem around.  You could set the value of a variable from the config file, then it is easy to use that variable as the connection string source for your connection manager.  At the same time you can use a parent variable
    configuration to map that variable to variables in your child package.
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • What is the best practice to set Captivate variables from Get (less ideal) and Post (more ideal)?

    We are trying to set a couple of variables in Captivate 7 by posting the information from a URL. Is there a best practice for doing this, or does it require a custom JS or other call in order to do this?
    Essentially, we want to pass three variables from a URl to named variables in a Captivate 7 swf so that the information can be drawn from a database, and does not need to be entered by the user.
    Suggestions, thoughts, pointers to where we may be able to find this information - all would be greatly appreciated!

    Not sure how Captivate treats FlashVars internally, but the native html template includes a script to read URL parameters:
    var strURLFull = window.document.location.toString();
    var intTemp = strURLFull.indexOf("?");
    var strURLParams = "";
    then:
    if(strURLParams != "")
       so.addVariable("flashvars",strURLParams);
    It also has a script to add variables but you'd have to parse the variables first first to use it:
    so.addVariable("variable1", "value1");

  • ITunes Music Folder will not play from external hardrive after setting the correct path

    I've decided to try and create some more space for my music collection and decided to keep my entire iTunes library on a portable external hardrive. I researched how to do so online and was successful at first. I set the correct path from the advanced menu so that iTunes would recognize and save music to the folder on my HD. It worked fine last night, but today when I try and access it I get the, "could not be used because the original file could not be found. Would you like to locate it?" error message when I try and play a song anywhere in iTunes. I then tried to import the library from my external hardrive and then everything was duplicated. I some how reversed the duplication by using time machine and then redownloading iTunes, which is a riduculous story in itself, but thankfully, I am back at square one.
    I have over 24,000 songs with a majority of them rated as well as playlists I do not want to lose. I don't understand why it will not play the songs. Can anyone help me?

    If you are going to have the library on an ext HD the transfer the entire iTunes folder. This way you capture all the files - not just the music.
    Launch iTunes with the 'option' key down and follow the dialog - tell iTunes to open the iTunes library file on the ext HD and things should be ok.
    MJ

  • Set variable samples per chanel from counter

    Hi, all. I have to set variable samples per chanel for sample clock. I want to take that samples from counter input with different number of edges for every second (different speed of metal plate). What can i do for that task? Is there a god example for this problem?
    Thanks.

    Hi, GerdW. Thanks for reply. I want Sample Rate and Samples per Chanel to come from couter. CI is a metal plate with 52 tooth. The speed of metal plate is 500 cycles/min but it is not constant ( may be 490-520). For example rate of cycles is 500/60=8.33 cycles/sec. Rate of edges (tooth) is 8.33*52=433 edges/sec, but when speed goes over or under 500 the rate is different. How to put that variable samples in sample clock on AI?
    P.S. Matlab script is to calculate max samples per chanel for mean function in while loop. In the picture control "Speed cycles/min" is that 500 cycles/min speed. I have to put in that control the variable rate of edges. Other solution is to set 1 sample per edge, but i have problem here to .  

  • Simple question about environment variables and setting the class path???

    ok I have been trying for a few months now ontrying to set the class path..
    I work with windows vista..
    on the environment variables user variables,
    I have the name of the variable as class
    and the value as C:\Program Files\Java\jdk1.6.0_04\bin;.
    where javac is...
    on the system variables I have
    its name as class
    and the value as C:\Program Files\Java\jdk1.6.0_04\bin;.
    why is this not reading javac

    The PATH environment variable should have as an entry the directory containing your javac executable. The CLASSPATH should have have entries which define your library directories and entries which are your jar file libraries. In the early days, probably the only CLATHPATH entry you will need will be a '.' to indicate the current directory.
    The Java tutorial covers ALL of this.

  • How to get and set a session variable from backing bean?

    Hi im using Jdev 11.1.1.2.0 and i need to set and get a session variable from backing Bean.
    Any idea?

    the class :
    package arq.resources;
    import javax.faces.context.FacesContext;
    import javax.servlet.http.HttpSession;
    public class SesionSigef {
    public FacesContext context;
    public HttpSession session;
    public SesionSigef() {
    super();
    context = FacesContext.getCurrentInstance();
    session = (HttpSession)(context.getExternalContext().getSession(true));
    public Object getVariableSesion(String atributo){
    return session.getAttribute(atributo);
    public void setVariableSesion(String atributo,Object valor){
    session.setAttribute(atributo, valor);
    the example of use :
    SesionSigef se = new SesionSigef();
    DatosRec da = new DatosRec();
    da.setDocumentoCip("Aprobar");
    se.setVariableSesion("DatosRec", da);
    thanks
    Joaquin

Maybe you are looking for