Declaring a var

I am running into an issue with embedding javascript inside a servlet.
I have a method to generate a window to type in text. I want to use javascript to alert the user if they are passing in an invalid char.
here is what i have
any ideas, thanks in advance!
public Vector generateAddNoteWindow(String folder, String docId, int docNum, String servletPath) throws java.lang.Exception
     Vector data = new Vector();
     try
          data.add("<HTML><HEAD>");
          data.add("<script type='text/javascript'> ");
          data.add(" ");
          data.add(" function validate() ");
          data.add(" ");
          data.add("{");
          data.add(" x=noteform._text; ");
          data.add(" myval = x.value; ");
          data.add(" if (myval.length > 3) ");
          data.add(" {");
          data.add("var iChars = ^&[]<>; ");//i think this is my problem - is this the way to declare the var?????
          data.add("for (var i = 0; i < document.noteform._text.value.length; i++) ");
               data.add("{");
                    data.add("if (iChars.indexOf(document.noteform._text.value.charAt(i)) != -1) ");
                    data.add("{");
                         data.add("alert ('Your Annotation has special characters. \nThese are not allowed.\n Please remove them and try again.'); ");
                         data.add("return false ");
                    data.add("}");
               data.add("}");
          data.add(" return true ");
          data.add(" }");
          data.add(" else ");
          data.add(" { ");
          data.add(" alert('The note data field cannot be blank.'); ");
          data.add(" return false ");
          data.add(" } ");
          data.add("} ");
          data.add("</script> ");
          data.add("</HEAD><BODY>");
          data.add("<H3>You are about to add a note to report " + folder + "</H1>");
          data.add("<H4>Notes are limited to 255 characters!</H4>");
          data.add("<form name='noteform' method=POST action=" + servletPath + " onsubmit='return validate()'>");
            data.add("<input type=hidden name=_function value=addNoteToServer>");
            data.add("<input type=hidden name=_folder value=" + folder + ">");
            data.add("<input type=hidden name=_docid value=" + URLEncoder.encode(docId) +">");
            data.add("<input type=hidden name=_docNumber value=" + docNum +">");
            data.add("<textarea name=_text rows=5 cols=50 onKeypress='CountLetters()'></textarea><br><br><font size=2>");
            data.add("<font size=2>");
            data.add("<input type=submit value=Save>��");
          data.add("<input type=button value=Cancel onClick=history.back();>");
            data.add("</form></font></BODY>");
            data.add("<script type='text/javascript'>");
               data.add("function CountLetters()"); 
                    data.add("{");
                         data.add("if (document.noteform._text.value.length > 253)");
                         data.add("{");
                              data.add("alert('Notes cannot be over 255 characters, your note will be truncated to 255.');");
                         data.add("}");
                    data.add("}");
          data.add("</script>");
            data.add("</HTML>");
          return data;
     catch(Exception e)
          String strError;
          strError = "A error occurred in generateAddNoteWindow: " + e.toString() + System.getProperty("line.separator");
          throw new Exception(strError);
}

data.add("var iChars = ^&[]<>; ");//i think this is my problem - is this the way to declare the var?????I guess it's supposed to be a string, so use quotes for JS (single quotes save you from escaping):
data.add("var iChars = '^&[]<>'; ");May I humbly ask why all this stuff is delivered as a Vector (and not a String or written to the outgoing stream directly)?

Similar Messages

  • Declaring the var in the constructer

    How can someone do this without declaring the photos var before the constructer as a field?
    package org.robotlegs.demos.imagegallery.models.vo
        import mx.collections.ArrayCollection;
        [Bindable]
        public class Gallery
            public var photos:ArrayCollection = new ArrayCollection()

    Hi Nikos,
    By your saying that the declaring fields here out side the constructor..Do you really mean it...why because in your code you doesn't seem to have a
    constructor and you are actually trying to declare the variable outside the class infact but not outside the constructor..
    So you are trying to do the follwing which is wrong..:
    //Here you are declaring the variable outside the class indeed which is wrong..
    package org.robotlegs.demos.imagegallery.models.vo
         import mx.collections.ArrayCollection;
         public var photos:ArrayCollection = new ArrayCollection()
         [Bindable]
         public class Gallery
    Infact you should do this ....
    package org.robotlegs.demos.imagegallery.models.vo
         import mx.collections.ArrayCollection;
         [Bindable]
         public class Gallery
             public var photos:ArrayCollection = new ArrayCollection()
             //Your Constructor
             public function Gallery()
    Hope you understood my point....
    Thanks,
    Bhasker Chari

  • Using a var declared in a function outside that function

    Hey, i am trying to do something i thought wouldn't be difficult, but looks like i'm wrong.
    So this is a function that runs from the start (creationcomplete). Inside i declare a var txt (which is a string)
    public function sendString(Event:FlexEvent):void
    txt = "Voorbeeld van een band";
    I want to call that var outside of the function. So I make it bindable. it's also the reason why i call teh var just by "txt" in the functions above.
    [Bindable]
    public var resultName:String;
    Now, in this label i call the var txt. However, the label stays empty. Though I don't get any errors.
    <s:Label x="20" y="69" fontSize="16" text="{txt}"/>
    Can anyone help me fix this? I figure it should be rather easy, but still.
    Also, If i call the function from a mouseclick, will i get an error then since the label asks for a var that doesn't exist yet?
    Many thanks!

    Local variables can be seen or use databinding.  Try making an instance variable on the class/document

  • Question about duplicate var declaration....

    the ff. code will compile and run... my question is there's a duplicate var declaration
    (s var as a String type)...
    Big Q: "Why the compiler didnt complain about it?"
    it should be "duplicate var declaration" sort of thing......
    public class Bits {
         public static void main(String args[]){
                  new Bits();
        public Bits(){
             f1();
        private String s; // class var declaration, var name is "s"
        private void f1(){
           // another var declaration name "s", why the compiler dont complain about this!?!
             String s=new String("Hello World!");
             f2();
        private void f2(){
        // does this var "s" refers to the class var?
             System.out.println ("s: "+s); // the output is null
    }Thanks!

    Big Q: "Why the compiler didnt complain about it?"
    it should be "duplicate var declaration" sort of
    thing......Bcos one is a local variable and the other is an instance variable. They arent duplicates.
    > private String s; // class var declaration, var name is "s"
    >
    private void f1(){
    // another var declaration name "s", why the compiler dont complain about >this!?!
         String s=new String("Hello World!"); As i said b4, this is a local variable. Within the scope of this method, this variable hides the instance var, 's' , to access which, u will have to use this.s
    >
    private void f2(){
    // does this var "s" refers to the class var?Yes.
    System.out.println ("s: "+s); // the output is null//that's bcos u havent initialized it anywhere. Local variable have to be compulsorily initialized. Instance variables are initialized to null (if they are Object references)
    ram.

  • Accessing class var from main timeline

    Hi all! Well I've been working on this for a couple of days
    now and just can't seem to get it to work right...... I'm still
    getting my feet wet with as3 and like it more and more everytime I
    use it.... almost.
    Anyways, here's where I'm running into trouble.
    Here's a dumbed down version of my project with all the other
    usless drivel excluded. Basically what I'm trying to do is declare
    a var and give it a value in my class. Then I want to be able to
    display that value on the stage and use it in the main timeline.
    Seems simple enough....
    I need to be able to pass the var from the class to the main
    timeline for use.... Any help on this would be GREATLY appreciated.
    Thanks.

    kglad, worked like a charm in my short test file... however
    in my real world flash file the class takes a short time to
    actually compute the value of the variable. If I fire the trace
    from the main timeline it will display NaN b/c at the moment it
    fires the value of the var doesn't exist b/c it has yet to be
    calculated......
    I don't really know the best way to delay this... would the
    best way be to somehow add an event listener to listen to the var
    to see when it is assigned a value?.... I'm open to suggestions.
    btw, good catch on the assignment of a string value!!
    Thanks!

  • Very simple question about declaring variables

    if a create a new ' int ' as in the code below :
    static int counter;
    does the value of counter automatically default to ' 0 ' ?
    Does this also apply if i declare the var to be public, protected etc ( but not final )
    thanks

    Most languages will initialise an int to 0 if no value is specified but it is dangerous to rely on this as it is not always the case. It is therefore recommended as good practice that you always initialise your own variables to ensure they start with the value you wish and not something unexpected.
    Mark.

  • VAR syntax in business rule

    <p>Hi,</p><p>I'm trying VAR command in busines rule.</p><p> </p><p>Type of local variables declared by VAR in business rule can benumeric only?</p><p>I shoud use string variables.</p>

    Solution found:
    Click on RuleSet which you have created.
    Expand Rule inside it.
    Enable Advanced mode and Tree mode and click OK.
    Select Root as Task and click on insert pattren and create pattren which is based on unbounded element (here its meant as fact)
    Once you create pattren , will be able access elements under unbounded element for Business rule configuration.

  • Unable to see custom Trace messages in Log Viewer which were defined in UDF

    Hello Experts, I am not able to see my trace messages in Log Viewer. I have a small user defined fuction which takes a variable and returns its uppercase and while do that it writes few warning level trace messages in the trace file. I've tried changing the levels from Warning to Info but I still don't see anything in my Log Viewer. At this point I am not even sure if I am looking at right place. When I test my mapping in Message Mapping's Test tab it works fine and shows me all my trace messages. But when I do end to end it is not writing anything to the trace file. I've tried to use instructions from following blogs:
    1. /people/michal.krawczyk2/blog/2007/04/30/xipi-personalized-logging-tracing(logging and tracing)
    2. /people/michal.krawczyk2/blog/2005/05/10/xi-i-cannot-see-some-of-my-messages-in-the-sxmbmoni (logging and tracing)
    3. /people/michal.krawczyk2/blog/2005/02/25/simple-java-code-in-graphical-mapping--xi(for my UDF)
    but I still don't see traces in my Log Viewer. Please let me know if I am doing anything wrong here.
    Thanks in advance!!
    ==============================================================
    public String TraceVar(String var1, Container container) throws StreamTransformationException{
    AbstractTrace importanttrace; //create an instace of AbstractTrace
    importanttrace = container.getTrace(); //get trace
    importanttrace.addWarning("FiletoFileMP:MyUdflibrary: " + var1); //write first message to the trace
    // fix the naming conventions later
    String SenderName; // declare multiple vars to store infos
    String ReceiverName;
    String interface_name;
    String message_ID;
    String time_Sent;
    java.util.Map map;
    map = container.getTransformationParameters();
    //get interface info into the variables
    time_Sent = (String) map.get(StreamTransformationConstants.TIME_SENT);
    message_ID = (String) map.get(StreamTransformationConstants.MESSAGE_ID);
    interface_name = (String) map.get(StreamTransformationConstants.INTERFACE);
    SenderName = (String) map.get(StreamTransformationConstants.SENDER_NAME);
    ReceiverName = (String) map.get(StreamTransformationConstants.RECEIVER_NAME);
    //post interface info to the trace
    importanttrace.addWarning("Time Sent: " + time_Sent);
    importanttrace.addWarning("Message ID: " + message_ID);
    importanttrace.addWarning("Interface Name: " + interface_name);
    importanttrace.addWarning("Sender Name: " + SenderName);
    importanttrace.addWarning("Receiver Name: " + ReceiverName);
    //convert var1 to uppercase to make sure this function has be executed
    return var1.toUpperCase();
    Edited by: Mayur Patel on May 5, 2009 11:03 PM

    Thank you Prateek for a quick response.
    Yes I was able to see my trace messages in SXMB_MONI. Below is my the info... This is great. I am still not sure why this info is not showing up in Log Veiwer's (default trace) window. Any ideas? Since this XML file contains lots of other information I was wondering how to put my trace messages into the log viewer.
    Thanks!!
      <Trace level="1" type="T">*** START APPLICATION TRACE ***</Trace>
      <Trace level="2" type="T">FiletoFileMP:MyUdfLibrary: Honda</Trace>
      <Trace level="1" type="T">FiletoFileMP:MyUdfLibrary: Honda</Trace>
      <Trace level="1" type="T">Time Sent: 2009-05-05T16:16:39Z</Trace>
      <Trace level="1" type="T">Message ID: 366CEAF14D3B410033AFDDB71CD2AF73</Trace>
      <Trace level="1" type="T">Interface Name: SIC_Car_Outbound</Trace>
      <Trace level="1" type="T">Sender Name: SIC_Car_Outbound</Trace>
      <Trace level="1" type="T">Receiver Name: SI_Car_Inbound</Trace>
      <Trace level="1" type="T">*** END APPLICATION TRACE ***</Trace>

  • Problem with pl/sql table data type

    hai friends,
    i have one procedure it has some in parameters and one out parameter which fetches values to front end.
    But the out parameter will be pl/sql table data type.
    if it is ref cursor
    then i declared as
    var x refcursor;
    exec procedure_name(1,:x);
    it is ok.
    but for pl/sql table data type is out parameter then what i will do in the prompt .
    give me syntax and clarify my doubt.
    advanced thanks...
    madhava

    The SQL*Plus VARIABLE statement does not support user-defined types, hence it cannot support nested tables. It can support cursors because they can be weakly typed (so we can use the one SQL*Plus VAR to hold any shape of resultset). Nested tables are strongly typed; SQL*Plus is a relatively stupid interface and cannot be expected to understand UDT.
    So, it you want to use nested tables as output you'll need to code a wrapping procedure that can understand your nested table type and handle it accordingly.
    Sorry.
    Cheers, APC

  • Sharing script to create slideshow

    Thanks for David Torno I have been able to hack together a basic slideshow script. There's still a lot more that could be done with it, but I wanted to share it so that others may be able to benefit.
    Essentially, it asks for a folder location where your photos are stored, reads them in, creates a comp for each photo, resizing them and creating a border around them, adds all of the photo comps to a master comp, then sequences them, adds in some fades and slightly random placement.
    Like I said, fairly basic. But quite the learning experience.
    Yes, there are templates available for slideshows, but none that I found that I could just add photos to and say "Display these with a border and random placement on the screen, fading in and out." All the ones I found required replacing placeholders, or some sort of manual changes to each photo. And they were generally limited to 10 to 30 images. This script, theoretically, should be able to handle hundreds of images easily.
    Next steps are to add movement to the photos (sliding across the screen as they fade in and out) and add a music track from a file (or files) selected during photo import.
    Enjoy!
    And thanks again to David Torno, plus anyone else who's script examples I may have borrowed ideas from.
    Dion
        createSlidehow v 1.0
        Developer: Dion Vansevenant
        Based on David Torno's "fileToCompToQ"
        This script creates a basic slideshow from a folder of images
         function createSlideshow(){
              try{
                   /*     DECLARE VARIABLES     */
                   var localFolder, renderToFolder, outputModuleName, jpgAEFolderName, compAEFolderName, newJPGParentFolder, myImportedFiles, newCompParentFolder, newCompParentFolder, grabFiles, grabFilesLength, extAry, compFrameRate;
                   /*     BEGIN VARIABLES TO CUSTOMIZE     */
                   jpgAEFolderName = "Photos";          //Folder name for imported files
                   compAEFolderName = "Photo_Comps";     //Folder name for resulting comps
                   extAry = new Array("jpg", "jpeg");               //Array of Strings. These are the file extension types you wish to import.
                   compFrameRate = 29.97;                                   //Frame rate for the newly created comps. Must be a float or integer value.
                   compDuration = 5;                                        //The duration of time, in seconds, that the new comps will be.
                    //masterComp Variables
                    var compWidth = 1920;  
                    var compHeight = 1080;  
                    var compPAR = 1;  
                    var compDur = 10;
                    var compFPS = 29.97;
                    //Create Master Comp
                    var masterComp = app.project.items.addComp("MASTER", compWidth , compHeight, compPAR, compDur, compFPS);
                    /*     END VARIABLES TO CUSTOMIZE     */
                   /*     START PROCESS     */
                    localFolder = Folder.selectDialog("Please select folder containing your JPG files.");                
                    // localFolder = new Folder("~/Desktop/Photos/");
                    if(localFolder != null && localFolder.exists == true){
                        app.beginUndoGroup("fileToCompToQ");
                             grabFiles = localFolder.getFiles();     //Retrieves all enclosed files
                             grabFilesLength = grabFiles.length;
                             //Process files
                             app.project.items.addFolder(jpgAEFolderName);     //Creates folder
                             newJPGParentFolder = findItem(jpgAEFolderName);     //Saves it for later use
                             extensionFilterAndImporter(grabFiles, grabFilesLength, extAry, newJPGParentFolder); //Imports files and puts them in a folder
                             myImportedFiles = storeFileObjsIntoArray(newJPGParentFolder);
                             //Process comps
                             app.project.items.addFolder(compAEFolderName);
                             newCompParentFolder = findItem(compAEFolderName);                                                 
                             createCompsAddToQ(newCompParentFolder, myImportedFiles, compFrameRate, compDuration);
                            addCompsToMaster(app.project);
                            mySequenceToLayer(compObj);
                            writeLn("All done");     //Adds this text to the Info Panel as a way to see when the script is done working.
                        app.endUndoGroup();
                   /*     END PROCESS     */
                   ///     FUNCTIONS     ///
                    // Add fades in and out to comps
                    function addFadeToComps(layerObj){
                        try{
                           // alert("Oops, module addFadeToComps is not ready yet");   
                           //alert("Entering addFadeToComps...");
                           var overLap = 1;
                           //alert("Working on layer "+layerObj.name+" with startTime of "+layerObj.startTime+" and outPoint of "+layerObj.outPoint);
                           layerObj.opacity.setValueAtTime(layerObj.inPoint, 0);                                                           
                           layerObj.opacity.setValueAtTime((layerObj.inPoint + overLap), 100);
                           layerObj.opacity.setValueAtTime((layerObj.outPoint - overLap), 100);
                           layerObj.opacity.setValueAtTime(layerObj.outPoint, 0);                                                           
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                    } // end function addFadeToComps
                    // Add fades using Expressions
                    function addExpFadeToComps(layerObj){
                        try{
                            var myLayer = layerObj;
                            var myLayerOpacityProperty = myLayer.property("ADBE Transform Group").property("ADBE Opacity");                       
                            //Frames that fade will take place over
                            var fade = "30";                        
                            //encoded expression string with "fade" variable inserted                       
                            var myExpress = "fadeTime%20=%20" + fade + ";%0DopacityMin%20=%200;%0DopacityMax%20=%20100;%0DlayerDuration%20=%20outPoint%20-%20inP oint;layerDiff%20=%20outPoint-(layerDuration/2);%0DsingleFrame%20=%20thisComp.frameDuratio n;%0DanimateIn%20=%20linear(time,%20inPoint,%20(inPoint%20+%20framesToTime(fadeTime)),%20o pacityMin,%20opacityMax);%0DanimateOut%20=%20linear(time,%20(outPoint%20-%20framesToTime(f adeTime+1)),%20(outPoint-singleFrame),%20opacityMax,%20opacityMin);%0Dif(time%20%3C%20(lay erDiff) )%7B%0D%09animateIn;%0D%7Delse%7B%0D%09animateOut;%0D%7D";
                            //Applies expression
                            myLayerOpacityProperty.expression = decodeURI(myExpress);
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                    } // end function addExpFadeToComps
                    // Add items to comp in reverse order to preserve numbering
                    function addCompsToMaster(projObj){
                        try{                   
                            for (var i = projObj.numItems; i != 0; i--){                                              
                                if (app.project.item(i) instanceof CompItem){ // <-- adds comps to the comp, but also tries to add MASTER, not good
                                    if (app.project.item(i).name != "MASTER"){ // <-- ok, filter out MASTER
                                        masterComp.layers.add(app.project.item(i),compDuration);
                                        compObj = app.project.item(1);
                                        layerObj = app.project.item(1).layer(1);
                                        layerObj.property("ADBE Transform Group").property("ADBE Opacity").setValue(0);
                                        addExpFadeToComps(layerObj);                                   
                                        imageSizeToCompSize(compObj, layerObj);
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}                
                     } // end function adCompsToMaster
                    // adds a white solid to create a border
                    function  addBorderToComps(compObj){
                        try{
                            var myBorder = compObj;
    //                        myBorder.layers.addSolid([1.0,1.0,0], "Frame", 50, 50, 1);
                            myBorder.layers.addSolid([1.0,1.0,1.0], compObj.name+"_Frame", compObj.width, compObj.height, 1);
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}                
                    } // end function addBorderToComps
                    // Loop through MASTER comp and manually do "Sequence Layers" to stagger start times.
                    // Also try to randomize placement of images on-screen
                    function mySequenceToLayer(compObj){
                        try{
                        // get number of items in MASTER comp
                            var numItems = compObj.numLayers;                   
                            for(i=2; i<=numItems;i++){
                                app.project.item(1).layer(i).startTime = app.project.item(1).layer(i-1).outPoint-2;
                                maxZ = compHeight-100;
                                minZ = 600;
                                maxX = compWidth-100;
                                minX = 600;
                                x = Math.random(minX,maxX)*100;
                                y = Math.random(minY,maxY)*100;
                                var myProperty = app.project.item(1).layer(i).position;
                                // If the result is even, add x,y change, otherwise subtract it
                                myEvenOdd = i%2;
                                if (myEvenOdd == 0){
                                    var newX = myProperty.value[0] + x;
                                    var newY = myProperty.value[1] + y;
                                }else{
                                    var newX = myProperty.value[0] - x;
                                    var newY = myProperty.value[1] - y;
                                myProperty.setValue([newX,newY,0]);
                            app.project.item(1).duration = Math.round(app.project.item(1).layer(numItems).outPoint);
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                    } // end function mySequenceToLayer
                    /*     findItem() function
                            Arguments::
                                itemName: Name of the After Effects folder to find. Must be a String.
                    function findItem(itemName){
                        try{
                             var allItems = app.project.numItems;
                             for(var i=1; i<=allItems; i++){
                                  curItem = app.project.item(i);
                                  if(curItem instanceof FolderItem && curItem.name == itemName){
                                       return curItem;
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                    } // end function findItem
                   /*     extensionFilterAndImporter() function
                        Arguments::
                             grabFiles:     Array of file objects
                             grabFilesLength:     Value must be an integer
                             extAry:     Array of Strings
                             newParentFolder:     String
                   function extensionFilterAndImporter(grabFiles, grabFilesLength, extAry, newParentFolder){
                        try{
                             var fileName, extPrep, ext, extAryLength, importOpt, newFile;
                             extAryLength = extAry.length;
                             for(var i=0; i<grabFilesLength; i++){
                                  fileName = grabFiles[i].displayName
                                  extPrep = fileName.split(".");
                                  ext = extPrep[extPrep.length-1].toLowerCase();
                                  for(var e=0; e<extAryLength; e++){
                                       if(ext == extAry[e]){
                                            writeLn(fileName);
                                            importOpt = new ImportOptions(grabFiles[i]);
                                            newFile = app.project.importFile(importOpt);     //Imports file into project
                                            moveItemToFolder(newFile, newParentFolder);     //Moves file into parent folder
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                   } // end function extensionFilterAndImporter
                   /*     moveItemToFolder() function
                        Arguments::
                             projectItem:     Must be an AVItem
                             parentFolder:     Must be a FolderItem
                   function moveItemToFolder(projectItem, parentFolder){
                        try{
                             projectItem.parentFolder = parentFolder;
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                   } // end function moveItemToFolder
                   /*     storeFileObjsIntoArray() function
                        Arguments::
                             sourceFolder:     Must be a FolderItem
                   function storeFileObjsIntoArray(sourceFolder){
                        try{
                             var itemAry, itemsInFolder, itemsInFolderLength;
                             itemAry = new Array();
                             itemsInFolder = sourceFolder.items;
                             itemsInFolderLength = itemsInFolder.length;
                             for(var i=1; i<=itemsInFolderLength; i++){
                                  itemAry[itemAry.length] = itemsInFolder[i];
                             return itemAry;
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                   } // end function storeFileObjsIntoArray
                   /*     createCompsAddToQ() function
                        Arguments::
                             myImportedFiles:     Array of File objects
                             fps:                         Must be a float or integer value.
                   function createCompsAddToQ(compAEFolderName, myImportedFiles, fps, duration){
                        try{
                             var myImportedFilesLength, curFile, extFind, fileNameOnly, newComp;
                             myImportedFilesLength = myImportedFiles.length;
                             for(var c=0; c<myImportedFilesLength; c++){
                                  curFile = myImportedFiles[c];
                                  extFind = curFile.name.toString().lastIndexOf(".");
                                  fileNameOnly = curFile.name.substring(extFind, 0);     //Removes file extension
                                  newComp = app.project.items.addComp(fileNameOnly+"_Comp", curFile.width, curFile.height, 1, duration, fps);     //Creates new comp
                                  addBorderToComps(newComp);
                                  newComp.layers.add(curFile);     //Adds file to comp
                                  imageSizeToBorderSize (newComp, 5);                             
                                  moveItemToFolder(newComp, compAEFolderName);     //Moves new comp to folder
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                   } // end function createCompsAddToQ
                    // resize layer to comp
                    function imageSizeToCompSize(compObj, layerObj){
                        try{
                            var curLayerBoundry, curLayerScale, newLayerScale, myNewLayerScale;
                            curLayerBoundry = layerObj.sourceRectAtTime(0,false);
                            curLayerScaleObj = layerObj.property("ADBE Transform Group").property("ADBE Scale");
                            curLayerScaleVal = curLayerScaleObj.value;
                            newLayerScale = curLayerScaleVal*Math.min(compObj.width/curLayerBoundry.width, compObj.height/curLayerBoundry.height);
                            myNewLayerScale = newLayerScale*.75;
                            curLayerScaleObj.setValue(myNewLayerScale);
                        }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                    } // end function imageSizeToCompSize
                    // resize image to less than frame
                   function imageSizeToBorderSize(compObj, frameOffset){
                       try{                       
                            var curLayerBoundry, curLayerScale, newLayerScale, myNewLayerScale;
                            layerPhotoObj = compObj.layer(1);
                            layerFrameObj = compObj.layer(2);
                            curLayerBoundry = layerPhotoObj.sourceRectAtTime(0,false);
                            curLayerScaleObj = layerPhotoObj.property("ADBE Transform Group").property("ADBE Scale");                       
                            curLayerScaleVal = curLayerScaleObj.value;                       
                            if (frameOffset != 0){
                                newScale = 100-frameOffset;
                                layerPhotoObj.scale.setValue([newScale,newScale,100]);
                            }else{
                                layerPhotoObj.scale.setValue([95,95,100]);
                       }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
                   } // end function imageSizeToBorderSize
               }catch(err){alert("Error at line# " + err.line.toString() + "\r" + err.toString());}
           } // end function fileToCompToQ
         createSlideshow(this);
    } // end script

    DECLARE @Query VARCHAR(MAX)=''
    DECLARE @DbName VARCHAR(400) = '<DBNAME>'
    DECLARE @DbFilePath VARCHAR(400) = '<Valid DataFilePath>'
    DECLARE @DBLogFilePath VARCHAR(400)='<Valid LogFile Path>'
    SET @Query = @Query + 'CREATE DATABASE '+@DbName +' ON PRIMARY '
    SET @Query = @Query + '( NAME = '''+@DbName +''', FILENAME = '''+@DbFilePath+@DbName +'.mdf'' , SIZE = 3072KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) '
    SET @Query = @Query + ' LOG ON '
    SET @Query = @Query + '( NAME = '''+@DbName +'_log'', FILENAME = '''+@DblogFilePath+@DbName +'_log.ldf'' , SIZE = 1024KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)'
    print @query
    exec(@query)
    --Prashanth

  • Can't save file on iOS device with low free space available

    Hi,
    I was using SharedObject to save settings in my game. However, recently I discovered on one of our devices it doesn't work. I've found somewhere on this forum discussion that air can't save sharedobject when available space is lower than about 300mb (link here: Bug#3711301 - sharedobjects fail when available storage is low). On my iphone it's about 40mb, but file, which I want to save is just 2 variables.. persistenceManager doesn't work too (well i've looked at source and it's just using SharedObject). So i've decided to just write file by myself:
    declarations:
    public var mute:Boolean = false;
    public static var fullId:String = "";
    then in constructor:
    flash.net.registerClassAlias("Settings", GameSettings);
    load();
    and finally save() and load() functions:
    public function save():void
      try {
      log("begin save()");
      var file:File = File.applicationStorageDirectory.resolvePath("settings.txt");
      var stream:FileStream = new FileStream();
      stream.open(file, FileMode.WRITE);
      var settings:GameSettings = new GameSettings();
      settings.fullId = fullId;
      settings.mute = mute;
      stream.writeObject(settings);
      stream.close();
      log("end save()");
      catch (error:Error) {
      log("[ERROR] " + error.name + ": " + error.message + "\n" + error.getStackTrace());
      public function load():void
      try {
      log("begin load()");
      var file:File = File.applicationStorageDirectory.resolvePath("settings.txt");
      if(!file.exists){
      log("settings.txt does not exist, created new one..");
      save();
      return;
      var stream:FileStream = new FileStream();
      stream.open(file, FileMode.READ);
      var settings:GameSettings = stream.readObject() as GameSettings;
      mute = settings.mute;
      fullId = settings.fullId;
      log("loaded mute = " + mute);
      log("loaded fullId = " + fullId);
      stream.close();
      log("end load()");
      catch (error:Error) {
      log("[ERROR] " + error.name + ": " + error.message + "\n" + error.getStackTrace());
    My GameSettings class:
    package
      public class GameSettings
      public var fullId:String;
      public var mute:Boolean;
      public function GameSettings()
    This works on desktop, android. Works on my ipad too, which has 10gb of free space. However, like I said, it doesn't work on iphone5s with 40mb free memory.
    Here's a log:
    begin load()
    settings.txt does not exist, created new one..
    [ERROR] Error: Error #0
         at Autumn/save()
         at Autumn/load()
         at Autumn()
    It's clear that AIR can't open or write to 'settings.txt' file. What can I do to solve that issue (other than making more free space on iphone)? Is there any workaround for that?

    Any help please?

  • Can't figure out how to make this script work

    Hey Folks,
    Anyone here who would like to look at the following script and tell me where I made the error(s)?
    I want to put this script in a Batch so that I can run it on a directory of files all with filenames like
    Q-CAT 2010-01 Covers_v7bP01x.pdf and
    Q-CAT 2010-01 Covers_v7bP02x.pdf
    I put this script in the correct spot, but nothing happens... I tried the debugger console, and I get:
    Begin Job Code
    Processing File #1
    State P01 detected
    Batch aborted on run #1Error: NotAllowedError: Security settings prevent access to this property or method.
    End Job Code
    This is the script, it's supposed to run in Acrobat 9:
    /* Q-CatCoverPagesSaveAs */
    /* this script Crops CatCovers' Spreads and saves it into separate pages */
    /* ©20100521 - AOP-Creatives, Willy Croezen */ 
    // Begin Job 
    if ( typeof global.counter == "undefined" ) { 
    console.println("Begin Job Code"); 
    global.counter = 0; 
    // insert beginJob code here 
    // Main Code to process each of the selected files 
    try { 
    global.counter++ 
    console.println("Processing File #" + global.counter); 
    // insert batch code here. 
    function doCropPages()
       this.setPageBoxes({
          cBox: "Crop",
          rBox: cropLeft
        app.beginPriv();
    console.println("Save LeftPageName");
    //       this.saveAs(this.path.slice(1, fname.indexOf(pageSide)) + leftPageName);
        app.endPriv(); 
       this.setPageBoxes({
          cBox: "Crop",
          rBox: cropRight
       app.beginPriv();
    console.println("Save RightPageName");
    //      this.saveAs(this.path.slice(1, fname.indexOf(pageSide)) + rightPageName);
       app.endPriv();
    //Declaration List
    var Units = "mm"; 
    var i = this.path.search(/[^:/]+\.pdf$/);
    var fname = this.path.slice(i, this.path.length - 4);
    var cropRect = this.getPageBox("Crop"); 
    //Check if filename contains P01, indicating the Outside spread of a Catalog Cover. If so, crop accordingly
    if (fname.indexOf("P01") != 0)
    console.println("State P01 detected");
       var pageSide = "P01";
       var leftPageName = "P260.pdf";
       var rightPageName = "P001.pdf"; 
       var cropLeft = new Array();
          cropLeft[0] = cropRect[0];
          cropLeft[1] = cropRect[1];
          cropLeft[2] = cropRect[2];
          cropLeft[3] = cropRect[3] + 277.5; 
       var cropRight = new Array();
          cropRight[0] = cropRect[0];
          cropRight[1] = cropRect[1];
          cropRight[2] = cropRect[2] + 223.5;
          cropRight[3] = cropRect[3] - 62;
       doCropPages();
    else
       //If filname does NOT contain P01, check if filename contains P02, indicating the Inside spread of a Catalog Cover. If so, crop accordingly
       if (fname.indexOf("P02") != 0)
    console.println("State P02 detected");
          var pageSide = "P02";
          var leftPageName = "P002.pdf";
          var rightPageName = "P259.pdf";
          var cropLeft = new Array();
             cropLeft[0] = cropRect[0];
             cropLeft[1] = cropRect[1];
             cropLeft[2] = cropRect[2];
             cropLeft[3] = cropRect[3] + 223.5; 
          var cropRight = new Array();
             cropRight[0] = cropRect[0];
             cropRight[1] = cropRect[1];
             cropRight[2] = cropRect[2] + 277.5;
             cropRight[3] = cropRect[3];
          doCropPages();
       else
          // If filename doesn't contain P01 OR P02, give Error notice
    console.println("Document is not correctly named! Should have P01 or P02 in it");
    catch(e) {
    console.println("Batch aborted on run #" + global.counter + "Error: " + e);
    delete global.counter; // so we can try again, and avoid End Job code
    event.rc = false; // abort batch
    // End Job
    if ( global.counter == global.FileCnt ) {
    console.println("End Job Code");
    // insert endJob code here
    // may have to remove any global variables used in case user wants to run
    // another batch sequence using the same variables, for example...
    delete global.counter;

    Hy Folks,
    This thread can be closed, as I fixed the script! It turned out that I needed to put the function definition above the body-code for the script to find it. After that it was small details.
    I created a conversion variable (UnitsConv) for the margins so you  can simply enter the desired dimensions in mm, instead of px, which I  thought was easier.
    This script now perfectly processes the files  you put to it in a batch-operation (if correctly named with P01 and P02  in the filename.) and saves the resulting pages into the specified  temp-directory. This time the filenames reflect the original filenames,  for easy identification later, with the new pagenumbers appended to  them.
    For your information (and perhaps for use as the base for a custom  script for yourself) I give you the final working version below.
    This script will be trimmed down and become part of a larger script, or scriptset, which I will be using to automate the workflow of creating al different versions of lowres and highres catalogs that we need.
    Kind regards,
    Willy Croezen
    /* Q-CatCoverPagesSaveAs v1.0*/
    /* this script Crops CatCovers' Spreads and saves it into separate pages */
    /* ©20100521 - AOP-Creatives, Willy Croezen */
    // Begin Job
    if ( typeof global.counter == "undefined" ) {
    console.println("Begin Job Code ");
    global.counter = 0;
    // insert beginJob code here
    // Main Code to process each of the selected files
    try {
    global.counter++
    console.println("Processing File #" + global.counter);
    // insert batch code here.
    function doCropPages(crL,crR,lPName,rPName)
       this.setPageBoxes({
          cBox: "Crop",
          rBox: crL
          console.println("Save LeftPageName to: D:/temp/" + lPName);
          this.saveAs("/D/temp/" + lPName);
       this.setPageBoxes({
          cBox: "Crop",
          rBox: crR
          console.println("Save RightPageName to: D:/temp/" + rPName);
          this.saveAs("/D/temp/" + rPName);
    //Declaration List
    var UnitsConv = (72 / 25.4);
    var i = this.path.search(/[^:/]+\.pdf$/);
    var fname = this.path.slice(i, this.path.length - 4);
    var cropRect = this.getPageBox("Crop");
    //Check if filename contains P01, indicating the Outside spread of a Catalog Cover. If so, crop accordingly
    if (fname.indexOf("P01") != -1)
    console.println("Value fname.indexOf(P01) = " + fname.indexOf("P01"));
    console.println("State P01 detected");
       var pageSide = "P01";
       var leftPageName = fname + "P260.pdf";
       var rightPageName = fname + "P001.pdf";
    // Create array of crop-values. Sequence is left, top, right, bottom
       var cropLeft = new Array();
          cropLeft[0] = cropRect[0];
          cropLeft[1] = cropRect[1];
          cropLeft[2] = cropRect[2] - Math.floor(277.5 * UnitsConv);
          cropLeft[3] = cropRect[3];
       var cropRight = new Array();
          cropRight[0] = cropRect[0] + Math.floor(223.5 * UnitsConv);
          cropRight[1] = cropRect[1];
          cropRight[2] = cropRect[2] - Math.floor(62 * UnitsConv);
          cropRight[3] = cropRect[3];
       doCropPages(cropLeft,cropRight,leftPageName,rightPageName);
    else
       //If filname does NOT contain P01, check if filename contains P02, indicating the Inside spread of a Catalog Cover. If so, crop accordingly
       if (fname.indexOf("P02") != -1)
    console.println("State P02 detected");
          var pageSide = "P02";
          var leftPageName = fname + "P002.pdf";
          var rightPageName = fname + "P259.pdf";
    // Create array of crop-values. Sequence is left, top, right, bottom  
          var cropLeft = new Array();
             cropLeft[0] = cropRect[0];
             cropLeft[1] = cropRect[1];
             cropLeft[2] = cropRect[2] - Math.floor(223.5 * UnitsConv);
             cropLeft[3] = cropRect[3];
          var cropRight = new Array();
             cropRight[0] = cropRect[0] + Math.floor(277.5 * UnitsConv);
             cropRight[1] = cropRect[1];
             cropRight[2] = cropRect[2];
             cropRight[3] = cropRect[3];
          doCropPages(cropLeft,cropRight,leftPageName,rightPageName);
       else
          // If filename doesn't contain P01 OR P02, give Error notice
    console.println("Document is not correctly named! Should have P01 or P02 in it");
    catch(e) {
    console.println("Batch aborted on run #" + global.counter + "Error: " + e);
    delete global.counter; // so we can try again, and avoid End Job code
    event.rc = false; // abort batch
    // End Job
    if ( global.counter == global.FileCnt ) {
    console.println("End Job Code");
    // insert endJob code here
    // may have to remove any global variables used in case user wants to run
    // another batch sequence using the same variables, for example...
    delete global.counter;

  • How do I get this loop to give me numbers within a range?

    So for a school assignment I need to get a loop to display all the numbers in a certain range. This range is input by the user with a starting number and an end number. For some reason when i put the code in all its giving me is the end number and not the numbers between the start and end. I was wondering if someone could show me what to tweak to fix it. This is the code so far...
    // Add event listener
    submit_btn.addEventListener(MouseEvent.CLICK, onClick);
    function onClick(event:MouseEvent):void {
    // Declare Variables
    var startInput:String;
    var endInput:String;
    var startNum:Number;
    var endNum:Number;
    // Get Start Value from Text Field
    startInput=start_txt.text;
    // Convert value from string to number
    startNum = Number(startInput);
    // Get End Value from Text Field
    endInput=end_txt.text;
    // Convert value from string to number
    endNum = Number(endInput);
    // For loop
    for (var range:int = startNum; range <= endNum; range++ )
        response_txt.text = "The numbers between the inputed integers are " + range + "!";
    I've also include the actual program so you can see it if you want to test it..
    Thanks for your help,
    The Student of Flash

    Being that you're a student and this is an assignment, I have to honor what I believe the intentions of the assignment are, which is for you to solve it and get it working, not for someone else to hand you the solution.  But I can offer a hint...
    It's not a question of slowing it down, it's a question of controlling what gets written to the output textfield when.  If you did the trace you saw that it was rewriting the textfield in each loop.  So just as a hint, look up the appendText() method of the TextField class.

  • Accessing an Array in a duplicated movie clip

    I have a movie clip that has a script declaration of:
    var myCGroup:Array = Array();
    in the first frame.
    (I've also tried var myCGroup:Array; var myCGroup:Array = new
    Array(); and var myCGroup:Array = []; )
    I duplicate this movie clip multiple times. I'm having
    trouble targeting the variable myCGroup from elsewhere in the
    timeline. Other non-array variables that are declared in the same
    place are fully accessible.
    The only code I've been able to write that writes to this
    variable is:
    eval(targetThumb).myCGroup = prodFlush[2].childNodes;
    which actually takes the childnodes and creates an array with
    them.
    However, reading them back out from a separate function later
    is impossible:
    trace("colors to target =====" +
    eval(masterProds[sm]).myCGroup);
    returns nothing. I can read and write to other variables from
    the same function using the same targeting.
    (yes, materProds[sm] == targetThumb)
    Also, the following code results in an undefined array:
    // for(cg=0;cg<cGroupArray.length;cg++){
    eval(targetThumb).myCGroup.push(cGroupArray[cg].firstChild.nodeValue);
    // trace("time: " + cg + " || adding this color group " +
    cGroupArray[cg].firstChild.nodeValue + " to product: "+ targetThumb
    + "===== " + eval(targetThumb).myCGroup)
    Is this a bug, or a documented local vs. global variable
    option that I'm unaware about regarding arrays?
    Any other thoughts? I'm at my wits end.
    Thanks in advance.
    -r

    question[i] =  questionSet.getString(i);Try:
    question[i] =  questionSet.getString(1);Or better still:
    question[i] =  questionSet.getString("QUESTION");or "ANSWER" for the anser record set.
    ResultSet.getString(int) looks up the value in a column (starting at index 1) in a result set.
    getString(String) looks up the value in a column by column name.

  • Customized Top Level Navigation iView

    Hello to all
    We are using a customized TLN iview. Its source code was modified to admit different URLs, and do the filtering depending of the default framework page which is using the TNL iview,
    I mean, the TLN would be copied inside a proyect folder on the Portal Content, where would be a DFPage that contains a copy of TNL iview, and this copy would have a different roleFilter attribute.
    Then, the TLN was modified again in order to merge roles that had the same name.
    Those changes doesn't seem really important, they have just declared some vars, and each of them added one code line. The first one extended the first part of an IF condition, and the second one extended it with another condition, using OR.
    The problem is that after the modifications, our TLN doesn't highlight correctly the first node when accessing or refreshing the Portal, instead of it shows a default start page that doesn't belong to any of our roles
    The TLN iview has a procedure named PrintNavNodes, which is called on the event OnClick (I assume), and when we accessrefresh the page too.
    The iview works well when clicking its buttons, it's just the first time it is used when the wrong page is shown, that's the problem we need to correct.
    This procedure (PrintNavNodes) lodges the code changes. The only var modified is String prefix, so maybe anyone could tell me a default value to it, o a way to catch that mistake in order to show another page when the default page is to appear.
    Also, I would appreciate if anyone knows about an API, andor a How to... manual, or any kind of documentation about this subject.
    We have no possibility of reject the changes, so we need to find an alternative solution. Here is the code...
    Thanks in advance, and regards
        private void PrintNavNodes(IPortalComponentRequest request, IPortalComponentResponse response)
         ILogger loggerArquitectura = request.getLogger(portal_logger);
             String strDataToPrint=;
         NavigationEventsHelperService navHelperService = (NavigationEventsHelperService)PortalRuntime.getRuntimeResources().getService(com.sap.portal.navigation.helperservice.navigation_events_helper);
         NavigationNodes initialNodes = navHelperService.getRealInitialNodes(request);       
    !-- Change Heiko Broker for SiteNavigation          
              IPortalComponentContext componentContext = request.getComponentContext();
              IPortalComponentProfile profile = componentContext.getProfile();
              String roleFilter = profile.getProperty(RoleFilter);
            if(initialNodes != null)
         INavigationNode firstChild = null;
         INavigationNode firstContent = null;          
         String prefix=ROLESportal_content;
    !-- Change Marta Alberto
         PROBLEM In the new TLN, when using the merge roles feature, the
         url of the merge roles is different (start with the word merge.....).
         This is a wrong implementation because it filters all the nodes that do
         not start with ROLES.
         SOLUTION Compare with the other prefix too.
         String newPrefixThatFixesTheProblem=MERGESportal_content;          
         String newPrefixThatFixesTheProblem=merge(;
                if(initialNodes.size()  0)      
                for(Iterator it = initialNodes.iterator(); it.hasNext();)
                    INavigationNode initialNode = (INavigationNode)it.next();
                        strDataToPrint=initialNode.getName(),;
    !-- Change Heiko Broker for SiteNavigation          
         if (initialNode.getName().startsWith(prefix+roleFilter)
    !-- Change Marta Alberto
         PROBLEM In the new TLN, when using the merge roles feature, the
         url of the merge roles is different (start with the word merge.....).
         This is a wrong implementation because it filters all the nodes that do
         not start with ROLES.
         SOLUTION Compare with the other prefix too.
          initialNode.getName().startsWith(newPrefixThatFixesTheProblem + prefix + roleFilter))                    
                         firstContent = PrintNode(initialNode, request, response, 0);
                         if(firstChild == initialNode)
                             if(firstChild.getLaunchURL() != null && !firstChild.getLaunchURL().equals())
                                 firstContent = firstChild;
                             else
                             if(firstContent == null)
                                 try
                   firstContent = firstChild.getFirstChild();
                                 catch(NamingException e)
                   ILogger logger = request.getLogger(navigation_logger);
                   if(logger != null && logger.isActive())
                        logger.severe(this, e, Exception in Top Level Navigation);
                             HttpSession httpSession = request.getServletRequest().getSession();
                             httpSession.setAttribute(NavFirstContentNode, firstContent);
                }  end FOR
            response.write(););

    Hi,
    Check authentication related properties of iView. Make sure all of them are set to lowest level or none
    Regards,
    Ganga

Maybe you are looking for

  • Playing music off and external hard drive

    I've been thinking about getting another hard drive whos sole purpose will be house my (somewhat large) CD library. Though I'm not sure if I import the CDs and drag their files to the other HD that i'll be able to just hook up the hard drive and open

  • Oracle express vs regular edition

    how are you? wanted to ask you the following: i am doing an online course in PL/SQl (see below for syllabus) and originally i installed an Oracle Express 10 edition. my instructor though told me that i should install a regular edition because 'expres

  • Error in Client copy

    Hi Team, We got a problem during client import because of the transaction log being full.We observe that the transaction log space in initially at 95 % free but when we start the import job its keep on growing drastically and reaching its maximum ava

  • IPhone 4 mms message send failure

    Anybody else having problems with this??? I spoke to tech support and they had me resest network settings. It worked when they sent me a mms and I sent one back to them. But when I tried to send a test mms to one of my contacts, it wouldnt send it.

  • Stop 3D rotation

    I need help with this file. here is a link to what the file looks like: http://www.itwithintegrity.com/ I incorporated these orbs into a .fla file that I purchased online. I have changed a little bit of the action script, but it is basically the same