Location of variable and function names in SWF bytecode?

Ok, so I'm looking at the specification PDF for v10 of a SWF file.
Here is a link to it: http://www.adobe.com/devnet/swf/pdf/swf_file_format_spec_v10.pdf
I can't find anything in there about where or how a SWF stores variable and function names in the bytecode, though SWF decompilers can find them in any SWF file. So they must be in there somewhere.
Can any one help me on this one?

Hi check the varaibles by giving ur tech.name of report input parameter to the below program,
RSRQ_QUERYDEFINITION
it will all the query details. So you can find ur varaibles where it is used exactly.
bhaskar

Similar Messages

  • Accessing variables and functions between loaded external swfs?

    Using AS 3.0: Say I have a menu.swf that loads a content.swf
    below it using the following
    var newContent:Loader = new Loader();
    newContent.load(new URLRequest("fowContent.swf"));
    addChildAt(newContent,0);
    Now say I have a frame label in newContent that is an
    animation ending the display of that swf. Upon clicking of another
    menu button in menu.swf, can I access the content's ending sequence
    by:
    newContent.gotoAndPlay(newContent.endingSequence);
    Also can you use while loops in AS 3.0? I would like to have
    a boolean variable "ended" in the newContent that becomes true
    after the ending animation has played.
    while ( newContent.ended != true)
    //wait
    then have it run the function to load and display the new
    content.swf

    quote:
    Originally posted by:
    kglad
    p.s. you can't use a for-loop and you can't use a while-loop
    to effect any time delays. they both execute from beginning to end
    before anything is updated on-stage and no other code can execute
    outside of those loops (unless called from within the loop).
    Thank you very much for the help.
    Would I need to declare a MovieClip variable before using
    that statement or does that automatically cast newContent as a
    movieclip and go to the frame?
    So in order to achieve the flow I'm looking for.
    I'll have this in the menu.swf looking for clicks. It will
    run a function in the content.swf that runs the ending sequence and
    receives a string variable which is a concatenation of the
    buttonclicked (which is also the filename of next content) and
    .swf. (can I cast the event.target.name into a string the same way
    you casted the other into a movieclip?)
    function buttonClick(event:MouseEvent):void //in the menu.swf
    var nextFile:string = string(event.target.name) + ".swf";
    MovieClip(newContent.contentLoaderInfo.content).endSequence(nextFile)
    fowContent.addEventListener(MouseEvent.CLICK, buttonClick);
    In the content.swf I will have a public variable nextContent
    and the function that the menu.swf calls, which begins the ending
    sequence.
    public var nextContent:string;
    function endSequence(nextFile:string)
    nextContent = nextFile;
    gotoAndPlay(endingSequence);
    Then at the end of the movie sequence I could call this
    function that passes back the variable that was modified by the
    previous function and runs the loader.
    parent.loadNext(nextContent) //in the content.swf
    function loadNext(nextContent:string) //function in menu.swf
    newContent.load(new URLRequest(nextContent));
    addChildAt(newContent,0);
    I'm sure theres a better way to do this, and I don't even
    know if this will work. But I'd like to make sure it makes sense
    before I try to implement it.

  • Error- Unexpected Signal : 11 and Function name=pthread_key_delete

    Really hoping that someone might be able to help us with this problem.
    We use Apache with a Tomcat, RedHat 7.2, JDK 1.3.1_02 and a postgreSQL database.
    Thanks in advance for any help.
    We have run a deamon on our system and sometimes we get a unexpected exception like this:
    An unexpected exception has been detected in native code outside the VM.
    Unexpected Signal : 11 occurred at PC=0x40025bc6
    Function name=pthread_key_delete
    Library=/lib/i686/libpthread.so.0
    Cannot obtain thread information
    Dynamic libraries:
    08048000-0804c000 r-xp 00000000 68:01 181728 /usr/java/jdk1.3.1_02/bin/i386/native_threads/java
    0804c000-0804d000 rw-p 00003000 68:01 181728 /usr/java/jdk1.3.1_02/bin/i386/native_threads/java
    40000000-40016000 r-xp 00000000 68:01 508012 /lib/ld-2.2.4.so
    40016000-40017000 rw-p 00015000 68:01 508012 /lib/ld-2.2.4.so
    40018000-40019000 r--p 00000000 68:01 491538 /usr/lib/locale/en_US/LC_IDENTIFICATION
    40019000-4001a000 r--p 00000000 68:01 49508 /usr/lib/locale/en_US/LC_MEASUREMENT
    4001a000-4001b000 r--p 00000000 68:01 393306 /usr/lib/locale/en_US/LC_TELEPHONE
    4001b000-4001c000 r--p 00000000 68:01 393863 /usr/lib/locale/en_US/LC_ADDRESS
    4001c000-40029000 r-xp 00000000 68:01 131197 /lib/i686/libpthread-0.9.so
    40029000-40031000 rw-p 0000c000 68:01 131197 /lib/i686/libpthread-0.9.so
    40031000-4003a000 r-xp 00000000 68:01 378355 /usr/java/jdk1.3.1_02/jre/lib/i386/native_threads/libhpi.so
    4003a000-4003b000 rw-p 00008000 68:01 378355 /usr/java/jdk1.3.1_02/jre/lib/i386/native_threads/libhpi.so
    4003b000-4022b000 r-xp 00000000 68:01 115881 /usr/java/jdk1.3.1_02/jre/lib/i386/client/libjvm.so
    4022b000-40329000 rw-p 001ef000 68:01 115881 /usr/java/jdk1.3.1_02/jre/lib/i386/client/libjvm.so
    40340000-40343000 r-xp 00000000 68:01 508037 /lib/libdl-2.2.4.so
    40343000-40344000 rw-p 00002000 68:01 508037 /lib/libdl-2.2.4.so
    40344000-40476000 r-xp 00000000 68:01 132807 /lib/i686/libc-2.2.4.so
    40476000-4047c000 rw-p 00131000 68:01 132807 /lib/i686/libc-2.2.4.so
    40481000-40494000 r-xp 00000000 68:01 508042 /lib/libnsl-2.2.4.so
    40494000-40495000 rw-p 00012000 68:01 508042 /lib/libnsl-2.2.4.so
    40497000-404b9000 r-xp 00000000 68:01 131195 /lib/i686/libm-2.2.4.so
    404b9000-404ba000 rw-p 00021000 68:01 131195 /lib/i686/libm-2.2.4.so
    404ba000-404ee000 r-xp 00000000 68:01 295089 /usr/lib/libstdc++-2-libc6.1-1-2.9.0.so
    404ee000-404fa000 rw-p 00033000 68:01 295089 /usr/lib/libstdc++-2-libc6.1-1-2.9.0.so
    404fc000-4050d000 r-xp 00000000 68:01 115900 /usr/java/jdk1.3.1_02/jre/lib/i386/libverify.so
    4050d000-4050f000 rw-p 00010000 68:01 115900 /usr/java/jdk1.3.1_02/jre/lib/i386/libverify.so
    4050f000-40530000 r-xp 00000000 68:01 115891 /usr/java/jdk1.3.1_02/jre/lib/i386/libjava.so
    40530000-40532000 rw-p 00020000 68:01 115891 /usr/java/jdk1.3.1_02/jre/lib/i386/libjava.so
    40533000-40547000 r-xp 00000000 68:01 115901 /usr/java/jdk1.3.1_02/jre/lib/i386/libzip.so
    40547000-4054a000 rw-p 00013000 68:01 115901 /usr/java/jdk1.3.1_02/jre/lib/i386/libzip.so
    4054a000-4127b000 r--s 00000000 68:01 279835 /usr/java/jdk1.3.1_02/jre/lib/rt.jar
    412a8000-4154d000 r--s 00000000 68:01 279826 /usr/java/jdk1.3.1_02/jre/lib/i18n.jar
    4154d000-41563000 r--s 00000000 68:01 279836 /usr/java/jdk1.3.1_02/jre/lib/sunrsasign.jar
    4360b000-4360c000 r--p 00000000 68:01 393862 /usr/lib/locale/en_US/LC_NAME
    4360c000-4360d000 r--p 00000000 68:01 475291 /usr/lib/locale/en_US/LC_PAPER
    4360d000-4360e000 r--p 00000000 68:01 131181 /usr/lib/locale/en_US/LC_MESSAGES/SYS_LC_MESSAGES
    4360e000-4360f000 r--p 00000000 68:01 49292 /usr/lib/locale/en_US/LC_MONETARY
    4360f000-43610000 r--p 00000000 68:01 491850 /usr/lib/locale/en_US/LC_TIME
    49c6f000-49c75000 r--p 00000000 68:01 327799 /usr/lib/locale/en_US/LC_COLLATE
    49c75000-49c76000 r--p 00000000 68:01 458866 /usr/lib/locale/en_US/LC_NUMERIC
    49c76000-49ca1000 r--p 00000000 68:01 458876 /usr/lib/locale/en_US/LC_CTYPE
    49ca1000-49ca5000 r--s 00000000 68:01 182059 /usr/java/jdk1.3.1_02/jre/lib/ext/pop3.jar
    49ca5000-49caf000 r-xp 00000000 68:01 508058 /lib/libnss_files-2.2.4.so
    49caf000-49cb0000 rw-p 00009000 68:01 508058 /lib/libnss_files-2.2.4.so
    4a51c000-4a528000 r--s 00000000 68:01 182050 /usr/java/jdk1.3.1_02/jre/lib/ext/activation.jar
    4a528000-4a59f000 r--s 00000000 68:01 182051 /usr/java/jdk1.3.1_02/jre/lib/ext/cryptix32.jar
    4a59f000-4a5b9000 r--s 00000000 68:01 182052 /usr/java/jdk1.3.1_02/jre/lib/ext/imap.jar
    4a5b9000-4a6af000 r--s 00000000 68:01 180385 /usr/java/jdk1.3.1_02/jre/lib/ext/libereco.jar
    4a6af000-4a6f4000 r--s 00000000 68:01 182054 /usr/java/jdk1.3.1_02/jre/lib/ext/mail.jar
    4a6f4000-4a71a000 r--s 00000000 68:01 182055 /usr/java/jdk1.3.1_02/jre/lib/ext/mailapi.jar
    4a71a000-4a735000 r--s 00000000 68:01 182056 /usr/java/jdk1.3.1_02/jre/lib/ext/mm.mysql-2.0.4-bin.jar
    4a735000-4a77b000 r--s 00000000 68:01 180387 /usr/java/jdk1.3.1_02/jre/lib/ext/utils.jar
    4a77b000-4a788000 r--s 00000000 68:01 182058 /usr/java/jdk1.3.1_02/jre/lib/ext/mxlookup.jar
    4a788000-4a7c2000 r--s 00000000 68:01 182061 /usr/java/jdk1.3.1_02/jre/lib/ext/sapdbc-7.3.0.18.jar
    4a7c2000-4a7cc000 r--s 00000000 68:01 182062 /usr/java/jdk1.3.1_02/jre/lib/ext/servlet.jar
    4a7cc000-4a7cf000 r--s 00000000 68:01 182063 /usr/java/jdk1.3.1_02/jre/lib/ext/smtp.jar
    4a7cf000-4a844000 r--s 00000000 68:01 180226 /usr/java/jdk1.3.1_02/jre/lib/ext/iText.jar
    4a844000-4a846000 r--s 00000000 68:01 180378 /usr/java/jdk1.3.1_02/jre/lib/ext/jcert.jar
    4a846000-4a847000 r--s 00000000 68:01 180380 /usr/java/jdk1.3.1_02/jre/lib/ext/jnet.jar
    4a847000-4a8b9000 r--s 00000000 68:01 180381 /usr/java/jdk1.3.1_02/jre/lib/ext/jsse.jar
    4a8b9000-4a8cc000 r--s 00000000 68:01 180379 /usr/java/jdk1.3.1_02/jre/lib/ext/jce1_2_2.jar
    4a8cc000-4a8e6000 r--s 00000000 68:01 180227 /usr/java/jdk1.3.1_02/jre/lib/ext/jdom.jar
    4a8e6000-4aa9b000 r--s 00000000 68:01 180376 /usr/java/jdk1.3.1_02/jre/lib/ext/xerces.jar
    4aa9b000-4ab4c000 r--s 00000000 68:01 180375 /usr/java/jdk1.3.1_02/jre/lib/ext/xalan.jar
    4ab4c000-4ab4d000 r--s 00000000 68:01 180386 /usr/java/jdk1.3.1_02/jre/lib/ext/local_policy.jar
    4ab4d000-4ab6e000 r--s 00000000 68:01 180389 /usr/java/jdk1.3.1_02/jre/lib/ext/sunjce_provider.jar
    4ab6e000-4ab6f000 r--s 00000000 68:01 180391 /usr/java/jdk1.3.1_02/jre/lib/ext/US_export_policy.jar
    4ab6f000-4ab99000 r--s 00000000 68:01 180377 /usr/java/jdk1.3.1_02/jre/lib/ext/pg73jdbc2ee.jar
    4ab99000-4ac71000 r--s 00000000 68:01 182573 /usr/java/jdk1.3.1_02/jre/lib/ext/xercesImpl.jar
    4ac71000-4ac86000 r--s 00000000 68:01 182574 /usr/java/jdk1.3.1_02/jre/lib/ext/xmlParserAPIs.jar
    4ac86000-4ac88000 r--s 00000000 68:01 182575 /usr/java/jdk1.3.1_02/jre/lib/ext/javaxml2.jar
    4ac88000-4ac8a000 r--s 00000000 68:01 182576 /usr/java/jdk1.3.1_02/jre/lib/ext/jaxm-api.jar
    4ac8a000-4ac92000 r--s 00000000 68:01 182577 /usr/java/jdk1.3.1_02/jre/lib/ext/jaxr-api.jar
    4ac92000-4acdc000 r--s 00000000 68:01 182578 /usr/java/jdk1.3.1_02/jre/lib/ext/jaxr-apidoc.jar
    4acdc000-4adc0000 r--s 00000000 68:01 182579 /usr/java/jdk1.3.1_02/jre/lib/ext/jaxr-ri.jar
    4adc0000-4adc8000 r--s 00000000 68:01 182580 /usr/java/jdk1.3.1_02/jre/lib/ext/jaxrpc-api.jar
    4adc8000-4aee8000 r--s 00000000 68:01 182581 /usr/java/jdk1.3.1_02/jre/lib/ext/jaxrpc-ri.jar
    4aee8000-4aef1000 r--s 00000000 68:01 180392 /usr/java/jdk1.3.1_02/jre/lib/ext/cryptix-jce-api.jar
    4aef1000-4aef7000 r--s 00000000 68:01 180393 /usr/java/jdk1.3.1_02/jre/lib/ext/cryptix-jce-compat.jar
    4aef7000-4af38000 r--s 00000000 68:01 182582 /usr/java/jdk1.3.1_02/jre/lib/ext/cryptix-jce-provider.jar
    4af38000-4af54000 r--s 00000000 68:01 182583 /usr/java/jdk1.3.1_02/jre/lib/ext/cryptix-jce-tests.jar
    4af54000-4af58000 r--s 00000000 68:01 182584 /usr/java/jdk1.3.1_02/jre/lib/ext/cryptix-message-api.jar
    4af58000-4af93000 r--s 00000000 68:01 182585 /usr/java/jdk1.3.1_02/jre/lib/ext/cryptix-openpgp-provider.jar
    4af93000-4af98000 r--s 00000000 68:01 182586 /usr/java/jdk1.3.1_02/jre/lib/ext/cryptix-pki-api.jar
    4af98000-4af9c000 r--s 00000000 68:01 182587 /usr/java/jdk1.3.1_02/jre/lib/ext/certpath-api-compat.jar
    4af9c000-4afa5000 r--s 00000000 68:01 182588 /usr/java/jdk1.3.1_02/jre/lib/ext/ftp.jar
    4afa5000-4afc8000 r--s 00000000 68:01 180382 /usr/java/jdk1.3.1_02/jre/lib/ext/cryptix32-pgp.jar
    4afc8000-4afce000 r--s 00000000 68:01 182566 /usr/java/jdk1.3.1_02/jre/lib/ext/PagoStatusChangeHandler.class
    4afce000-4afd1000 r--s 00000000 68:01 182567 /usr/java/jdk1.3.1_02/jre/lib/ext/WhiteLabelStatusChange.class
    4afd1000-4afd4000 r--s 00000000 68:01 182568 /usr/java/jdk1.3.1_02/jre/lib/ext/WhiteLabelRefund.class
    4afd4000-4afe0000 r--s 00000000 68:01 182569 /usr/java/jdk1.3.1_02/jre/lib/ext/RegistrationForm.class
    4afe0000-4afe3000 r--s 00000000 68:01 182570 /usr/java/jdk1.3.1_02/jre/lib/ext/CancelViaPost.class
    4afe3000-4afe7000 r--s 00000000 68:01 182571 /usr/java/jdk1.3.1_02/jre/lib/ext/CancellationForm.class
    4afe7000-4afec000 r--s 00000000 68:01 182572 /usr/java/jdk1.3.1_02/jre/lib/ext/ArticleForm.class
    4afec000-4aff5000 r-xp 00000000 68:01 115898 /usr/java/jdk1.3.1_02/jre/lib/i386/libnet.so
    4aff5000-4aff6000 rw-p 00008000 68:01 115898 /usr/java/jdk1.3.1_02/jre/lib/i386/libnet.so

    In pthreads, the threading model that must be used in your system, thread local variables need to be implemented, and it appears as though during deallocation of this thread specific data is where it's dying. That said, I would attempt upgrading your pthread libraries, appearing as though there is nothing in Java that is going wrong. That doesn't mean unfortunately that this is the source of wrongdoing, but it couldn't hurt to eliminate.
    I know there is libpthread-0.10.so out there, so there should be /some/ update to it. Reply if you need specifics.

  • Variable and column name

    Hi all,
    In an interface, I've got a column which has the same name as a variable.
    When I execute it in ODI 10g all is fine.
    With ODI 11g, it replace the column name by the variable one. If the variable has no value, I've got an SQLException.
    I believe it comes from the colon.
    In the execution code, I have
    INSERT ... VALUES PROJECT.NAME instead of NAME.
    I assume that ODI interprets the NAME with the variable name instead of the column name.
    Has anyone experienced it ?
    Thanks.

    Hi,
    I just tried to reproduce your issue, I didn't experience the case where ODI takes variable name instead of column name. ODI should be able to differentiate between column name and variable name with '#' Symbol prefixed to it. Any name prefixed with #, ODI thinks thats a variable and, it need to be declared in a package.
    In your case, looks like issue is not with the NAME, its with variable having no value. May be that ODI 10g has a default value. However, if a variable has no value, its definitely going to fail the process.
    Regards,
    K

  • Sql query to list menus, submenus and function-names for all resp

    Hi,
    Please let me know one single sql query to list all the menus, submenus and user-function-names attached for all responsibilities
    Thanks...

    Hi,
    See the following threads.
    How to find All The Responsibilities with a specific Menu
    How to find All The Responsibilities with a specific Menu
    SQL query
    SQL query
    Regards,
    Hussein

  • APT - getting declared variables and parameter names

    Hi,
    I would like start using APT, but if I am not mistaken, there are severe limitations what you can do with the tool. How is it possible to get the declared name of variables or parameters and methods from the apt tool?
    @someAnnotation
    public void someMethod(A para1, B para2) {...}I would need to get the name of the method and the name of the parameters to generate new sourcecode (AspectJ -Source), how is this possible? Without the names I cannot call the method from another place right?
    Where can I find the planned features for APT? It is a pitty that the tool is in a way very powerful and in another so limitated because you cannot extract the sourcecode or names.
    Regards,
    Klaas

    What about getSimpleName? This method is defined on
    declarations.You know, ParameterDeclaration is a Declaration ...
    All of the declarations returned by
    the mirror API are for elements that exist inside
    classes, not inside methods.Huh? Parameters are an integral part of methods and methods are elements that exist inside classes (or types in general). What's your point?
    The apt API does not expose any information about the
    interiors of methods or constructors.Oh boy. For a ParameterDeclaration getSimpleName() will return the name of the parameter, e.g. suppose you are "scanning" a standard main method:public static void main(String[] args) {...}and you already have the ParameterDeclaration instance representing the sole parameter of the method, then getSimpleName() will return "args".
    BTW - this has nothing to do with exposing interiors. Just try it.

  • High number of "The connection has timed out" errors. Where do I set the time out period (variable and file name) - windows 7

    I usually use a wireless network at home and have very few time out problems with Firefox.
    I am travelling and using Optus Wireless broadband where the average ping to a site is 700+ms .
    I suspect that this is the cause of the high number of timeouts I am experiencing.
    Optus say there are no problems so I think I will have to set the timeout to a longer period.
    Please advise what variable name/s (and in which file) the timeout is set for LOADING PAGES.
    Thanks in anticipation.
    Greg Atkinson.
    By the way the same is happening in IE8
    and on many sites other than the Yahoo one below.
    ================Full Error Page ==============
    URL is http://au.mg4.mail.yahoo.com/dc/launch?.gx=1&.rand=81jkv757qfdqt
    =========================================
    The connection has timed out
    The server at au.mg4.mail.yahoo.com is taking too long to respond.
    * The site could be temporarily unavailable or too busy. Try again in a few moments.
    * If you are unable to load any pages, check your computer's network connection.
    * If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.

    Having the same problem 4 out of 5 times I try to navigate to a new site I get the error "connection has timed out".
    My I phone works fine on the same wireless connection so it must be something to do with the computer. The problem occurs on IE, firefox, and google chrome.
    I too would like to know how to how to either fix this problem or failing that to extend the length of time before the connection times out (which is currently only about 5 seconds).
    Please help!
    Thanks in advance

  • Can't Access MovieClips and Functions in Loaded SWF

    Hi everybody,
    I'm trying to simply access anything inside this loaded SWF and all I get is 'null'.
    I have code in the parent SWF that needs to tell the child SWF movieclip what to do but nothing works. This was a piee of cake in AS2 and I can't seem to get anything to crossover in AS3.
    Here's my code:
    import com.greensock.TweenMax;
    import flash.display.MovieClip;
    var myLoader:Loader = new Loader();
    var url:URLRequest = new URLRequest("SWCS_S3_500x250_exp_panel_2.swf"); // in this case both SWFs are in the same folder
    myLoader.load(url);  // load the SWF file
    panel2.addChild(myLoader);   // add that instance to the display list, adding it to the Stage at 0,0
    panel2 = myLoader.content as MovieClip;
    photo_about.alpha = 0;
    photo_downloads.alpha = 0;
    //panel2.content_about.alpha = 0;
    //panel2.content_downloads.alpha = 0;
    function closeSection():void
              panel2.controlsMC.forcePause();
              TweenMax.to(photo_about, .5, {alpha:0});
              TweenMax.to(photo_downloads, .5, {alpha:0});
              TweenMax.to(photo_home, .5, {alpha:0});
              TweenMax.to(panel2.content_about, .5, {alpha:0});
              TweenMax.to(panel2.content_downloads, .5, {alpha:0});
              TweenMax.to(panel2.controlsMC, .5, {autoAlpha:0});
              TweenMax.to(panel2.content_home, .5, {alpha:0});
    panel2 traces null and all the clips loaded within pull up undefined property errors.
    Can somebody please tell me what I'm doing wrong? I'd be stoked to know what I'm missing and feel like this should be a piece of cake.
    Thanks for any help!

    You are not adding the content to the stage at 0,0, you are adding it to panel2 at 0,0.  THen you take panel2 and assign it to be something that likely doesn't exist by the time you assign it.  You need to wait until the loader completes loading before you attempt to do anything with its content, otherwise it has no content (null).  Similarly, you cannot control anything in the loaded swf until it has finished loading.  So assign an event listener to the contentLoaderInfo property of the Loader to determine when loading is complete, and have the event handler function deal with starting the interaction with it.
    var myLoader:Loader = new Loader();
    var url:URLRequest = new URLRequest("SWCS_S3_500x250_exp_panel_2.swf");
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, processLoadedSWF);
    myLoader.load(url);
    function processLoadedSWF(evt:Event):void {
        // deal with the loaded swf here
        // but you don't want to be assigning it to the panel2 object that contains the loader
    As far as controlling anything inside the swf you load, is it an AS1/2 or an AS3 swf?

  • An object variable and class name

    How come some classes, such as wrapper classes, don?t use an object variable to call a method in their classes? For example, StingBuffer or String class needs an object variable to call its method but Double, Integer, Character, NumberFormat, or some other classes doesn?t use an object variable to call a method in its class. Why is that? Any suggestions? Any explanation would be helpful.

    errr.. do you mean static methods and instance methods?
    http://java.sun.com/docs/books/tutorial/java/javaOO/classvars.html

  • Javascript discussion: Variable scopes and functions

    Hi,
    I'm wondering how people proceed regarding variable scope, and calling
    functions and things. For instance, it's finally sunk in that almost
    always a variable should be declared with var to keep it local.
    But along similar lines, how should one deal with functions? That is,
    should every function be completely self contained -- i.e. must any
    variables outside the scope of the function be passed to the function,
    and the function may not alter any variables but those that are local to
    it? Or is that not necessary to be so strict?
    Functions also seem to be limited in that they can only return a single
    variable. But what if I want to create a function that alters a bunch of
    variables?
    So I guess that's two questions:
    (1) Should all functions be self-contained?
    (2) What if the function needs to return a whole bunch of variables?
    Thanks,
    Ariel

    Ariel:
    (Incidentally, I couldn't find any way of  marking answers correct when I visited the web forums a few days ago, so I gave up.)
    It's there...as long as you're logged in at least, and are the poster of the thread.
    What I want is to write code that I can easily come back to a few months later
    and make changes/add features -- so it's only me that sees the code, but
    after long intervals it can almost be as though someone else has written
    it! So I was wondering if I would be doing myself a favour by being more
    strict about make functions independent etc. Also, I was noticing that
    in the sample scripts that accompany InDesign (written by Olav Kvern?)
    the functions seem always to require all variables to be passed to it.
    Where it is not impractical to do so, you should make functions independent and reusable. But there are plenty of cases where it is impractical, or at least very annoying to do so.
    The sample scripts for InDesign are written to be in parallel between three different languages, and have a certain lowest-common-denominator effect. They also make use of some practices I would consider Not Very Good. I would not recommend them as an example for how to learn to write a large Javascript project.
    I'm not 100% sure what you mean by persistent session. Most of my
    scripts are run once and then quit. However, some do create a modeless
    dialog (ie where you can interface with the UI while running it), which
    is the only time I need to use #targetengine.
    Any script that specifies a #targetengine other than "main" is in a persistent session. It means that variables (and functions) will persist from script invokation to invokation. If you have two scripts that run in #targetengine session, for instance, because of their user interfaces, they can have conficting global variables. (Some people will suggest you should give each script its own #targetengine. I am not convinced this is a good idea, but my reasons against it are mostly speculation about performance and memory issues, which are things I will later tell you to not worry about.)
    But I think you've answered one of my questions when you say that the
    thing to avoid is the "v1" scope. Although I don't really see what the
    problem is in the context of InDesign scripting (unless someone else is
    going to using your script as function in one of theirs). Probably in
    Web design it's more of an issue, because a web page could be running
    several scripts at the same time?
    It's more of an issue in web browsers, certainly (which I have ~no experience writing complex Javascript for, by the way), but it matters in ID, too. See above. It also complicates code reuse across projects.
    Regarding functions altering variables: for example, I have a catalog
    script. myMasterPage is a variable that keeps track of which masterpage
    is being used. A function addPage() will add a page, but will need to
    update myMasterPage because many other functions in the script refer to
    that. However, addPage() also needs to update the total page count
    variable, the database-line-number-index-variable and several others,
    which are all used in most other functions. It seems laborious and
    unnecessary to pass them all to each function, then have the function
    alter them and return an array that would then need to be deciphered and
    applied back to the main variables. So in such a case I let the function
    alter these "global" (though not v1) variables. You're saying that's okay.
    Yes, that is OK. It's not a good idea to call that scope "global," though, since you'll promote confusion. You could call it...outer function scope, maybe? Not sure; that assumes addPage() is nested within some other function whose scope is containing myMasterPage.
    It is definitely true that you should not individually pass them to the function and return them as an array and reassign them to the outer function's variables.
    I think it is OK for addPage() to change them, yes.
    Another approach would be something like:
    (function() {
      var MPstate = {
        totalPages: 0,
        dbline: -1
      function addPage(state) {
        state.totalPages++;
        state.dbline=0;
        return state;
      MPstate = addPage(MPstate);
    I don't think this is a particularly good approach, though. It is clunky and also doesn't permit an easy way for addPage() to return success or failure.
    Of course it could instead do something like:
        return { success: true, state: state };
      var returnVal = addPage(MPstate);
      if (returnVal.success) { MPstate = returnVal.state; }
    but that's not very comforting either. Letting addPage() access it's parent functions variables works much much better, as you surmised.
    However, the down-side is that intuitively I feel this makes the script
    more "messy" -- less legible and professional. (On the other hand, I
    recall reading that passing a lot of variables to functions comes with a
    performance penalty.)
    I think that as long as you sufficiently clearly comment your code it is fine.
    Remember this sort of thing is part-and-parcel for a language that has classes and method functions inside those classes (e.g. Java, Python, ActionScript3, C++, etc.). It's totally reasonable for a class to define a bunch of variables that are scoped to that class and then implement a bunch of methods to modify those class variables. You should not sweat it.
    Passing lots of variables to functions does not incur any meaningful performance penalty at the level you should be worrying about. Premature optimization is almost always a bad idea. On the other hand, you should avoid doing so for a different reason -- it is hard to read and confusing to remember when the number of arguments to something is more than three or so. For instance, compare:
    addPage("iv", 3, "The rain in spain", 4, loremIpsumText);
    addPage({ name: "iv", insertAfter: 3, headingText: "The rain in spain",
      numberColumns: 4, bodyText: loremIpsumText});
    The latter is more verbose, but immensely more readable. And the order of parameters no longer matters.
    You should, in general, use Objects in this way when the number of parameters exceeds about three.
    I knew a function could return an array. I'll have to read up on it
    returing an object. (I mean, I guess I intuitively knew that too -- I'm
    sure I've had functions return textFrames or what-have-you),
    Remember that in Javascript, when we say Object we mean something like an associative array or dictionary in other languages. An arbitrary set of name/value pairs. This is confusing because it also means other kinds of objects, like DOM objects (textFrames, etc.), which are technically Javascript Objects too, because everything inherits from Object.prototype. But...that's not what I mean.
    So yes, read up on Objects. They are incredibly handy.

  • Dynamically create variables and names

    Hi,
    I am dealing with some software that will send
    me string variables and their values. I have
    to process each variable it sends me to get
    its value. The problem is I dont know how many
    its going to send me in advance, so I cant
    hard code the varible names into my class.
    At run time I will get a int. value as to the
    number of variables. An array won't work and
    a vector wont work cause I need to process
    each variable by its name. I also know that
    each variable name will be some alpha characters
    followed by a number. For example:
    int 6
    test1
    test2
    test3
    test4
    test5
    test6
    The next time it could be 50 ...or 1 or any number....
    Is there anyway I can get my class to dynamically
    delcare String variables and their names?.......

    Just use some kind of collection. If you know the alpha characters at compiletime you can use an array - instead of test1 to test6 as in you example, you'd get test[0] to test[5]. (or test[1] to test[6] if you want the numbers to match - just create the array one bigger than needed and leave the [0] unused.) If you don''t know the alpha characters you can use a HashMap or some similar collection, and use the strings "test1", "test2" etc. as keys.
    You can also make your own class to handle this, for example by wrapping some code around an array to simplify access to your Strings.

  • Variable scope with loaded external SWF's?

    I’ve got an SWF, call it calcLite, that will be deployed both independently (ie: attached to an HTML doc) and also imported at run time (linked as an external asset via the loader class) to another SWF, let’s call it calcPro. That part is working fine.
    I’ve got a global variable, gRunMode:String that calcLite must declare and set when it’s running independently, but must inherit when attached to calcPro (which will declare and set gRunMode before attaching calcLite).
    Here’s where I am:
    At the root of calcPro:
    var gRunMode:String = “touchScreen”;
    At the root of calcLite:
    var gRunMode:String = “web”
    if (this.parent == this.stage) {
         gRunMode = MovieClip(this.parent.parent.parent).gRunMode;
    I’ve also tried creating function in the parent to return gRunMode:
    At the root of calcPro:
    var gRunMode:String = “touchScreen”;
    function getRunMode():String {
         return gRunMode;
    At the root of calcLite:
    var gRunMode:String = “web”
    if (this.parent == this.stage) {
         gRunMode = MovieClip(this.parent.parent.parent). getRunMode();
    I’ve also tried the second technique, renaming the global in calcPro to gRunModeExe incase there was a naming violation. In all cases I get “attempt to access prop of a null” error. The construct MovieClip(this.parent.parent.parent).function() works, I use it later in the program for a different function and it’s fine, just doesn’t work here.

    My bad, I wrote the post from memory at home. My actual code properly tested the stage (!=) and would have worked EXCEPT under the following condition:
    This is my second project in a row that involved an SWF that must operate independently and also function as a loaded child to a bigger project. What I keep forgetting is that loaded content begins to execute IMMEDIATELY!!!, it does not wait to be attached to the stage. Further, loaded content does not have access to stage assets until it’s been attached, so any premature attempts to access global variables and functions from loaded clip to stage fail. A good explanation of these issues can be found here (scroll to middle of page, post by senocular titled Access to stage and root): http://www.kirupa.com/forum/showthread.php?p=1955201
    The solution was simple enough. If calcLite is running as a child, stop in frame 1 (before any other processing) and wait for calcPro to push us to the next frame (which happens after attachment to the stage). If calcLite is running independently skip the stop and proceed as normal.
    As for this.parent.parent.parent vs. this.parent.parent vs this.parent, since gRunMode is global within the calcPro scope any of these would probably work (although I’ve only tested the first option). The first parent references the loader object, the second parent references the movie clip to which the loader object is attached, and the third parent finally references root.

  • I'm getting a "The procedure entrypoint ssSr192x__​ssSr192drv​ssSrReset could no be located in the dynamic link library ssSR192x.d​ll" because the ActiveX instrument driver DLL doesn't have the function names in the export table.

    Is there a way for my CVI project to reference the functions in the ActiveX without including the instrument .fp in the project?
    Thanks much.
    I'm confused on how CVI uses ActiveX components and hope someone can help.
    I'm using an ActiveX driver from an instrument manufacturer and I use the .TLB to generate a .fp, .c, and .h file. If I register the .dll and load the .fp in my project, all is well. Unfortunately in my application the functions to control this instrument are in another DLL whose .lib I include in my CVI projec
    t. Running the CVI project this way gives me "The procedure entrypoint ssSr192x__ssSr192drvssSrReset could no be located in the dynamic link library ssSR192x.dll" because the instrument function names aren't in the export table in the instrument DLL. Non-ActiveX DLLs have the export tables so everything works for them.
    Program structure with non-ActiveX DLLs:
    CVI project (.exe with common.lib in project list)
    |
    V
    Common DLL (MeasDMM() with hp1234.lib in project list)
    |
    V
    Instrument DLL (hp1234_measure())
    Since I get a .c and .h file from the .TLB, I've tried recompiling the DLL (.dll and .lib produced) and the functions seem to work, but I get "Class not registered" errors unless I play games with the registry so I'm obviously violating numerous Microsoft rules!
    Is there a way for my CVI project to reference the functions in the ActiveX without including the instrument .fp in the project? Thanks much.
    Jeff Fish
    Advisory Test Engineer
    StorageTek

    Hello Jeff,
    Where were your getting the .lib file for the ActiveX DLL? Did you use the "hp1234"
    ActiveX driver generated by the "Create ActiveX Automation Controller" CVI Tool to build a static library? If you open an include file and choose Options >> Generate DLL..., it will generate source code or a static import library to load the specified DLL and load functions specified in the include file (this only works if the functions are exported from a DLL). However, in the case of our ActiveX Automation Controllers, ActiveX calls are used to access a DLL. This means that you do not need an import library. You should be able to open the "hp1234" source file and click Options >> Create Object File. Simply #include "hp1234.h" and add "hp1234.obj" to your Common DLL project;
    the .fp file is not necessary. If this does not answer your questions or if you experience further difficulty, please post further details on what you are doing and the errors that are being encountered ("play games with the registry" and "recompiling 'the' DLL" are a bit vague in this case).
    Jeremiah
    Applications Engineer
    National Instruments
    http://www.ni.com/ask

  • [JS CS3] Variable Function Name

    Hello everyone,
    Does anyone know if you can put a variable into a function name?
    Bellow is a function that I am working on to avoid using an if statement with 33 possiblilites. It does work but I get a "undefined is not an object error".
    function myFunction(){
    var myDoc = app.activeDocument;
    var myRootXMLElement = myDoc.xmlElements.item(0);
    var myData = myRootXMLElement.xmlElements.item("xyzTag");
    for (b = 2; b <= 34; b++){
    if(b = myData.contents){
    myNewFunction = "my"+b+"VariableFunction()";
    try{
    eval(myNewFunction);
    }catch(e){
    alert(e);
    Because this physically does what I intend it to do I believe this should work but I can't get past this error. Could someone please let me know if there is a way to make this error free?
    Regards,
    Brett

    Change this line:
    >if (b = myData.contents)
    to this:
    >if (b == myData.contents)
    and it probably works. It is possible to use variables and eval() to call functions. This script works ok:
    for (i = 0; i < 3; i++)
       f = 'my' + i + 'Func()'
       eval (f)
    function my0Func ()
       $.writeln ('this')
    function my1Func ()
       $.writeln ('that')
    function my2Func ()
       $.writeln ('and the other')
    Peter

  • Variable Function Names

    What I'm trying to do is add event listeners for each position up to the total of compPositions. This way, each one will have a dymanic function name. Right now, they all launch function "clicked1" but I can't figure out how to make it add numbers to the function name dynamically. Is there a different method I should be using to accomplish this goal?
    Right now, compPosition = 5 so it should create 5 event listners, but I want them each to have their own function they exucute.
              var i;
              for (i = 1; i < compPositions +1; i++)
                        currentPos = "pos" + i;
                        this["pos" + i].addEventListener(MouseEvent.CLICK, clicked1)
    Edit:
    Actually, after thinking about it, I think this is a better approach, but I'm not sure how to pass over a variable using a click event.
                var i;
                for (i = 1; i < compPositions +1; i++)
                      var currentPos; //now it's private to this for loop
                      currentPos = "pos" + i;
                      this["pos" + i].addEventListener(MouseEvent.CLICK, posClicked)
    In this version, I just need to pass over the currentPos variable to the function, but I'm not sure if that's possible.
    Thanks,
    Corey

    Before solving, I would caution why you need them to have a unique function/unique function name. You should be able to have them all hit the same function and do different logic within depending on the target.
    That aside, you could do something like this:
    for (i = 1; i < compPositions +1; i++)
              currentPos = "pos" + i;
              this["pos" + i].addEventListener(MouseEvent.CLICK, this["clicked" + i])
    However, you would have to manually define each function. Alternatively, you can use closures:
    for (i = 1; i < compPositions +1; i++)
      currentPos = "pos" + i;
      this["pos" + i].addEventListener(MouseEvent.CLICK, getFunction(i))
    function getFunction(i:int):Function
              return function(e:MouseEvent):void { trace("Clicked " + i); };
    EDIT:
    Using the closure method you could also pass the current pos if you needed to:
    for (i = 1; i < compPositions +1; i++)
      currentPos = "pos" + i;
      this["pos" + i].addEventListener(MouseEvent.CLICK, getFunction(i, currentPos))
    function getFunction(i:int, currentPos:String):Function
              return function(e:MouseEvent):void { trace("Clicked " + i + " currentPos = " + currentPos); };

Maybe you are looking for