Variable scope problem?

I am not quite sure if this is a scope problem at all, but it looks like one....
Here is the problem:
I have a class in which I define a variable x as folowing:
public class XX
public var x:Integer;
In my fx script file I give it a value:
var t: XX {
x: 10
and it seems that it is initialized... however when I try to use the variable inside the class XX, it cannot be done.
for example I what try to do is
public var yy = YY {
for (i in [1..x]){
...do something...
and the cycle is executed only once!
Is this due to my inexperience in javafx or it is a standard behavior?

Is this due to my inexperience in javafx or it is a standard behavior? Both? :-)
The classical way to compute a class variable from those initialized at construction time is to do that in an init (or postinit) block.
It isn't really a problem of scope, rather of order of initialization.

Similar Messages

  • Having Truble Reading and Echoing Using PHP in HTML. Possible Variable Scope Problem?

    Hey guys,
       Thanks for your always knowledgable help! Today I am working with displaying text from a text file in an HTML table using PHP. I can't get the data to display properly, I think it has something to do with the scope of the variables, but I am not sure. Here is the code I am struggeling with:
    <table width="357" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td width="165">Pizza 1</td>
        <td width="186"><? echo  $price['0']; ?></td>
      </tr>
      <tr>
        <td>Burger 1</td>
        <td><? echo $price['1']; ?></td>
      </tr>
      <tr>
        <td>Drink 1</td>
        <td><? echo $price['2']; ?></td>
      </tr>
    </table>
    In the above PHP (not shown) the array $price is filled properly (I tested by echoing each bit line by line) but by the time we get into the HTML it seems the array is empty or it is not liking how I am calling it. Does the scope of a PHP variable end with the closing "?>" tag? Am I missing something? Bellow is the full code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    body {
        background-color: #333;
        color: #FFF;
    </style>
    </head>
    <body>
    <?php
    $menu=fopen("prices.txt","r") or exit("Unable to open file!");
    $price=array();
    $priceposition=null;
    $tempstring;
    //This loop does all of the READING and populating of variables
    while(!feof($menu))
        //Check to see if this is the first pass, if not add one to the array possition
        if ($priceposition==null){
            $priceposition=0;
        else{
        $priceposition++;
        //populate the temparary string
        $tempstring = fgets($menu);
        //Populate the array if the temporary string is not a comment
        if(substr($tempstring,0,2) != "//"){
            $price['$priceposition']= $tempstring;
            echo $price['$priceposition'];
      //End of reading loop
    fclose($menu);
    ?>
    <table width="357" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td width="165">Pizza 1</td>
        <td width="186"><? echo  $price['0']; ?></td>
      </tr>
      <tr>
        <td>Burger 1</td>
        <td><? echo $price['1']; ?></td>
      </tr>
      <tr>
        <td>Drink 1</td>
        <td><? echo $price['2']; ?></td>
      </tr>
    </table>
    </body>
    </html>
    and you can run the code on my test server here: christianstest.info/phptest/readwritetesting/readtest.php
    thanks guys!

    MurraySummers wrote:
    Try changing this -
    fclose($menu);
    to this -
    fclose($menu);
    echo "<pre>";exit(print_r($price));
    and see what you get.
    Wow, what a great little peice of testing code, thanks! That showed me the problem right away! Is there any way to test your php line by line in Dreamweaver CS6? I am used to computer programing in Visual Studio and Eclipse where they have an option of running code line by line and seing how variables populate and change with each line of code execution. Or is thier a program that can do this for PHP?

  • Variable scope problem... I think...

    I am new to javascript writing and need a bit of help. I am writing a .jsp web page.
    I have a javascript function which is:
    var fso;
    var e;
    var theFiles = new Array();
    int fileCounter = 0;
    var TristateFalse = 0;
    var ForWriting = 2;
    var ForReading = 1;
    myActiveXObject = new ActiveXObject("Scripting.FileSystemObject");
    dataFile = myActiveXObject.GetFile("distPath.dat");
    text2 = dataFile.OpenAsTextStream(ForReading, TristateFalse);
    filepath = text2.ReadLine( );
    text2.Close( );
    function findFiles() {
    fso = new ActiveXObject("Scripting.FileSystemObject");
    e = new Enumerator(fso.GetFolder(filepath).files);
    for (e.moveFirst(); ! e.atEnd(); e.moveNext()) {
    theFiles[fileCounter] = e.item();
    fileCounter++;
    I call the function via onload in the <body onload="findFiles();">
    the function works, as I have validated that by adding document.writeln(theFiles[fileCounter]) in the above function and get the output I expect (all the files in the directory pointed to by the distPath.dat file.
    my problem is I want to display the
    theFiles[fileCounter] array data better so I coded a table as below:
    <table border="0" cellspacing="1" cellpadding="2" align="center" width="100%">
    <tr align="center" bgcolor="#EEEEEE" valign="top">
    <td> Filename </td>
    </tr>
    <% for (int i=0;i< fileCounter ;i++) { %>
    <tr align="center" bgcolor="#FFFFFF">
    <td> <%= theFiles %></td>
    </tr>
    <% } %>
    </table>
    when loading the page I get these errors:
    An error occurred at line: 128 in the jsp file: /passwordAdminViewValidUserIDlist.jsp
    Generated servlet error:
    fileCounter cannot be resolved
    (line 128 is the <% for (int i=0;i< fileCounter ;i++) { %> line)
    An error occurred at line: 130 in the jsp file: /passwordAdminViewValidUserIDlist.jsp
    Generated servlet error:
    theFiles cannot be resolved
    (line 130 is the <td> <%= theFiles %></td>
    line)
    can any one help?
    Thanks,
    K

    This is a serious mix between JSP -> Java Server Pages; and JavaScript. Java is not JavaScript. The JSP scriptlets (inside the <% %> tags) runs on the server, before the client (browser) sees the code. JavaScript runs on the client, after the JSP is done and over with.
    What does this mean? When your JSP is run, the JavaScript variables do not exist. JSP can't use them. When JavaScript runs, the JSP is done, so it can't be used to display the JavaScript variables.
    You will have to decide what you want to use, either Java or JavaScript. Note, in Java (JSP) you will not be able to access the .dat file if it lives on the client's machine. I don't know activeX, so I don't know if that is what you are doing in JavaScript or not...

  • Scop problem

    Hi ,
    I having a problem communicating with loaded swf inside main
    file.
    Im using that script to have a transition between external
    swf :
    http://www.kirupa.com/developer/mx2004/transitions.htm
    most of it working fine but im having problem communicating
    with variable:
    Stage.swf:
    The main movie start to play and on its last frame it has the
    following action:
    this._lockroot=true
    //loading the first movie after the animation finish
    _root.currMovie = "main";
    _root.MC_Container.loadMovie(_root.currMovie+".swf");
    stop();
    portfolio.swf
    Than I press on the portfolio button and I get another main
    portfolio swf that has external files loeaded as well.its dividing
    the portfolio into categories , each category loading external
    file.
    First frame:
    this._lockroot=true
    _root.currMovie = "portfolio_3d";
    _root.MC_Container.loadMovie("portfolio_3d.swf");
    midframe=10;
    stop();
    buttons :
    on (release) {
    if (_root.currMovie == undefined) {
    _root.currMovie = "portfolio_print";
    _root.MC_Container.loadMovie("portfolio_print.swf");
    } else if (_root.currMovie != "portfolio_print") {
    if (_root.MC_Container._currentframe >=
    _root.MC_Container.midframe) {
    _level.currMovie = "portfolio_print";
    _root.MC_Container.play();
    portfolio_3d.swf
    the external file that loaded into the portfolio file is for
    example : portfolio_3d.swf ,
    the first frame action:
    this._lockroot=true
    midframe=10;
    middle frame has a stop(); command
    the last frame loading the next after the current movie
    finish:
    _root.MC_Container.loadMovie(_root.currMovie+".swf")
    the problem is that in the portfolio page, when I click the
    sub categries(3d,print,etc) , I get always the same movie. It seems
    like the variable doesn’t see the movie in the lowest level.
    It seems like a scop problem
    my url :
    www.shaygaghe.co.il
    thanks for your time ,
    Shay Gaghe

    what is the script that you have on the buttons on the bottom
    of the page that are supposed to load the new content? I think it
    may have something to do with your lockroot.

  • Function scope problem

    Hi all,
    I am using a class-based system for all my actionscript, but
    am having trouble getting the following code to work properly, and
    I am pretty certain it is a scope issue.
    public function
    setNavButtons(prevStart:Number,prevEnd:Number,nextStart:Number,nextEnd:Number){
    var owner = this;
    if (prevStart != undefined){
    mcPropertiesNav.btnBack.onRelease = function():Void{
    owner.reloadView(prevStart,prevEnd);
    if (nextStart != undefined){
    mcPropertiesNav.btnNext.onRelease = function():Void{
    owner.reloadView(nextStart,NextEnd);
    I've traced it out and know that when I use the reloadView
    method, the prevStart and prevEnd parameters are being passed in as
    undefined. Does anyone know how I would reference these variables
    within the onRelease functions?
    Thanks in advance
    Robert

    In the code you are posting a scope problem can't be
    pinpointed. The arguments you are providing are local to the
    function so there is no problem there. We might be able to help if
    you post the complete class.

  • CF9 struct key and variable name problem

    Running CF 9 on Linux, the following produces unusual results:
    <cfscript>
        a = { '99' = "that", '8X' = "this"};
        writedump(a);
    </cfscript>
    The dump shows only the keypair with the key '99' and the value 'this'. #a['99']# produces "this". #a['8X']# produces "this" as well. It's as though CF cannot distinguish between the tokens '99' and '8X'. Note that implicit assignment is not implicated:
    <cfscript>
        blah['GNQ'] = 'bad struct';
        blah['H02'] = 'worse struct';
    </cfscript>
    This yields a struct with one member per structcount(), with a key-value pair of GNQ='worse struct', but the key 'H02' accesses the same value. structkeyexists(blah, 'H02') returns true.
    On our systems (we've tried CF 9 on separate RH 4 and RH5 machines) the problem is not limited to structs per se, and seems to persist even when other characters are involved in variable or struct key names:
    <cfscript>
        testb0 = "test";
        testao = "test2";
    </cfscript>
    This produces an error page with the message "can't load a null". However, the following is possible:
    <cfscript>
        testb0 = "test";
        writeoutput("b0 = #testb0#<br/>");
        writeoutput("ao = #variables['testao']#<br/>");
        writeoutput("#structkeyexists(variables, "testao")#");
    </cfscript>
    The above produces the output 'test' for the undeclared variable 'testao', and also thinks that variables.testao is in the variables scope, even though it hasn't been declared.
    A quick loop or two and we've found that our CF 9 installations cannot distinguish between 340 two letter sequences, in matched pairs, as in the following example:
    ao = B0
    ap = B1
    aq = B2
    ar = B3
    as = B4
    at = B5
    au = B6
    av = B7
    aw = B8
    ax = B9
    Case does not seem to matter, and as mentioned above, this 'blindness' appears to persist even when the strings are embedded in other strings. E.g., when used as key or variable names, the following are being treated by CF as equal:
    slap = slb1
    tape = tb1e
    apes = b1es
    Has anyone else experienced anything like this? Could there be some strange setting that is causing CF to interpret the templates using some otherworldy codepage in which these characters are equivalent? Could there be something wrong with our installation, and/or our OS?
    Any hints, confirmation of our findings, and/or refutation of same would be greatly appreciated - we were hoping to move to CF 9 from CF 8 this week, but this is quite a showstopper for us.

    I did restart but turns out I fed the updater the zip file (hf900-81860.zip) instead of the jar file (hf900-81860.jar).  Now it returns the correct results, "abc" (not "123").  I also confirmed that this problem was not fixed by "Cumulative Hot Fix 1 for Coldfusion 9".  And, I verified that it fixed the more widespread issue in my application.  Thank you guys!
    HotFix (thanks buglug):
    http://kb2.adobe.com/cps/825/cpsid_82547.html
    Related bugIDs:
    81860
    81884
    82491
    Related posts:
    http://stackoverflow.com/questions/2164472/bug-in-cf9-values-for-unique-struct-keys-refere nced-and-overwritten-by-other-key

  • 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.

  • Cfm template updating cfc variable scope

    Don't know if anybody's run into this before, but I ran into a strange issue with the variable scope in a cfc.  Basically, I have some application settings stored in a database table, and then I have a cfc saved to application scope in which I store the contents of the table in a variable scope query.  Within the cfc, I have a getter function that preforms a query of queries to pull the data I need.  I then have an admin screen within the application to update the settings.
    This is (very generally) what my cfc looks like:
    <cfcomponent  name="settings.cfc">
         <cffunction name="init" returntype="settings">  
              <cfset setAppSettings() />  
              <cfreturn this />  
         </cffunction>  
         <cffunction name="setAppSettings">  
              <cfquery name="variables.qrySettings" datasource="#application.dsn#">  
                   SELECT *
                   FROM SETTINGS
              </cfquery>  
         </cffunction>  
         <cffunction name="getAppSettings" returntype="query">  
              <cfargument name="id" />
              <cfset var local = structNew() />  
              <cfquery name="local.qryResult" dbtype="query">  
                   SELECT *
                   FROM variables.qrySettings
                   WHERE ID = <cfqueryparam value="#arguments.id#" cfsqltype="cf_sql_numeric" />  
              </cfquery>  
              <cfreturn local.qryResult />  
         </cffunction>  
    </cfcomponent>
    In onApplicationStart in Application.cfc, I have this line:
    <cfset  
    application.objSettings = createObject("component","settings").init() />

    Sorry, accidentally posted before I was done...
    Basically, the problem is that I have an admin screen that updates the settings.  I call the getter function in a cfm template, and I save the result to a variable called variables.qrySettings (same name as in the cfc) like this - <cfset variables.qrySettings = application.objSettings.getAppSettings(url.id) />.  For some reason, this seems to overwrite variables.qrySettings in the cfc.  Any ideas????

  • Variable Scope at package or interface level

    Hi,
    Can we set the ODI Project variable scope to package or interface level
    because in my project im using a last rundate refresh variable this variable value will be changed at the time of execution of each package.
    Thanxs
    Madhavi

    you can create it as "Not Persistent" and then its value exist per ODI session.
    In this way, several sessions can keep independent value to the same variable.

  • Scope problem

    here is the function:
    public void readVector(File file)
    AddressBook addressBook = new AddressBook();
    try
    String string, token1 ="", token2 ="", token3 ="", token4 ="",
    token5 ="", token6 ="";
    FileInputStream fis1 = new FileInputStream(file);
    BufferedReader in = new BufferedReader(new FileReader(file));
    StringTokenizer st;
    while((string = in.readLine()) != null )
    st = new StringTokenizer(string);
    token1 = (st.hasMoreTokens())?st.nextToken():"";
    token2 = (st.hasMoreTokens())?st.nextToken():"";
    token3 = (st.hasMoreTokens())?st.nextToken():"";
    token4 = (st.hasMoreTokens())?st.nextToken():"";
    token5 = (st.hasMoreTokens())?st.nextToken():"";
    token6 = (st.hasMoreTokens())?st.nextToken():"";
    Contact c = new Contact(token1, token2, token3, token4, token5, token6);
    addressBook.addContact(c);
    catch(Exception ex)//catch exception and print stacktrace if try fails
    ex.printStackTrace();
    problem- some how I need to return the addresBook to another class, I can't do this because of a scope problem. Also if a solution is possible how would I call teh function in my other class.
    if this function returns an addressbook
    the prototype would be:
    AddressBook readVector(File file);
    how would I call this functino from another class to obtain the addressbok.

    I dont know what you mean by scope problem. Maybe you wanna elaborate on that a bit more. However, returning AddressBook should be straightforward. You can actually do it in two slightly different ways.
    1. You can define your readVector() method to be static:
    public static AddressBook readVector(whatever arguments) {
    ....your code here...
    Assuming you defined this method in class "foo", you can call this method using foo.readVector(arguments). In your calling function, you will probably have something like:
    AddressBook addressbk = foo.readVector(arguments);
    2. If you dont want to make your readVector() static, you will have to instantiate the class which contains this method. Again assuming class "foo" contains a definition like:
    public AddressBook readVector(args) {
    ....your code...
    In your calling method you will do the following:
    foo foo_obj = new foo();
    AddressBook addrbk = foo_obj.readVector(arguments);
    Of course, in either case your foo class has to be visible to the calling method. If your foo class is part of a different package, you will need to import it in the calling class.

  • How to identify the bind variable peeking problem?

    How to identify the bind variable peeking problem whether my db hitting or not and how to resolve it?
    currently we are doing the dbms_stat of application schema's with gather auto option and i hope this option we take the histogram stats also. Is there any option to improve it and its highly transactions oltp env of 11g.

    What is your exact 4 digits Oracle version ?
    Bind peeking issues are supposed to be solved with adaptative cursor sharing in 11.1 and 11.2:
    11.1 http://download.oracle.com/docs/cd/B28359_01/server.111/b28274/optimops.htm#sthref919.
    11.2 http://download.oracle.com/docs/cd/E11882_01/server.112/e16638/optimops.htm#PFGRF94588
    which says also:
    >
    Adaptive cursor sharing is enabled for the database by default and cannot be disabled. Note that adaptive cursor sharing does not apply to SQL statements containing more than 14 bind variables.
    >
    Edited by: P. Forstmann on 10 nov. 2011 13:50

  • Variable scope in plsql package

    When I run the following package, proc2 is always printing the value of i = 1 even though proc1 is incrementing the value of i correctly? Could any one explain to me what is the problem with this code?
    CREATE OR REPLACE PACKAGE test_pkg
    is
    PROCEDURE proc1 (p_fetch_limit in number := 200);
    PROCEDURE proc2 (rec_id out number);
    END test_pkg;
    CREATE OR REPLACE PACKAGE BODY test_pkg
    IS
    cursor test_cur
    IS
    select new_app,
    card_number,
    process_flag,
    process_date,
    seq_number
    from wm_opt_scan_temp
    where process_flag = 'N' and process_date IS null
    and new_app = 'Y'
    order by seq_number;
    type test_cur_type IS table of test_cur%rowtype;
    cur_rec test_cur_type;
    i number := 1;
    l_rec_id number := 0;
    -- PROC1 --
    PROCEDURE proc1 (p_fetch_limit in number := 200)
    IS
    BEGIN
    open test_cur;
    loop
    fetch test_cur bulk collect into cur_rec limit p_fetch_limit;
    exit WHEN cur_rec.count = 0;
    for i in 1..cur_rec.count
    loop
    DBMS_OUTPUT.put_line('proc1 - i<'||i||'> seq#<'||cur_rec(i).seq_number||'> card#<'||cur_rec(i).card_number||'>');
    l_rec_id := 0;
    proc2(l_rec_id);
    END loop;
    END loop;
    CLOSE test_cur;
    COMMIT;
    DBMS_OUTPUT.put_line('proc1 procedure finished...');
    END proc1;
    -- PROC2 --
    PROCEDURE proc2 (rec_id out number)
    IS
    BEGIN
    DBMS_OUTPUT.put_line('proc2 started - i<'||i||'> seq#<'||cur_rec(i).seq_number||'> card#<'||cur_rec(i).card_number||'>');
    END proc2;
    END test_pkg;
    output is:
    Connecting to the database Test.
    proc1 - i<1> seq#<7841> card#<40992814376>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<2> seq#<8041> card#<40992779256>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<3> seq#<8241> card#<40992745696>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<4> seq#<12681> card#<40992814376>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<5> seq#<12682> card#<40992814375>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<6> seq#<12683> card#<40992814378>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<7> seq#<12684> card#<40992814379>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<8> seq#<12685> card#<40992745756>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<9> seq#<12686> card#<40992745757>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<10> seq#<12689> card#<40992814377>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<11> seq#<12690> card#<40992745755>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<12> seq#<12691> card#<40992745767>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<13> seq#<12692> card#<40992745771>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<14> seq#<12693> card#<40992745612>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<15> seq#<12694> card#<40992145673>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<16> seq#<12695> card#<40992745611>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<17> seq#<12697> card#<40992745661>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<18> seq#<12698> card#<40992745689>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 - i<19> seq#<12700> card#<40992745771>
    proc2 started - i<1> seq#<7841> card#<40992814376>
    proc1 procedure finished...
    Process exited.
    Disconnecting from the database Test.

    Assign it to a separate global variable, and don't name it "i" so that the global variable is visible within the for loop.
    As for Java, consider the following:
    public class Foo {
    private int i;
    public void proc1() {
    for (int i=0;i<10;i++) {
    // do stuff
    public void proc2() {
    System.out.println("i = "+i);
    Same problem: two variables in different scopes, both named "i".

  • BPEL variable access problem - ORABPEL-02118

    Hi,
    I have a method which accesses the variable of a BPEL process. It worked well with the Soa Suite 10.1.3.1, but I re-install the SOA Suite with the Advanced installation and applied the 10.1.3.3 patch and now I have this error message:
    0 - ORABPEL-02118
    Variant not found.
    The variant "PatientRecordVariable" has not been declared in the current scope. All variants must be declared in the scope before being accessed.
    Please check that the variant "PatientRecordVariable" is properly declared; otherwise there may be a misspelling in the name of the variant.
    <2007-07-26 11:56:27,829> <ERROR> <default.collaxa.cube> <BaseCubeSessionBean::logError> Error while invoking bean "instance manager": [com.collaxa.cube.engine.EngineException: Variant not found.
    The variant "PatientRecordVariable" has not been declared in the current scope.  All variants must be declared in the scope before being accessed.
    Please check that the variant "PatientRecordVariable" is properly declared; otherwise there may be a misspelling in the name of the variant.
    ORABPEL-02118
    Variant not found.
    The variant "PatientRecordVariable" has not been declared in the current scope. All variants must be declared in the scope before being accessed.
    Please check that the variant "PatientRecordVariable" is properly declared; otherwise there may be a misspelling in the name of the variant.
         at com.collaxa.cube.engine.core.Scope.getVariantRV(Scope.java:522)
         at com.collaxa.cube.engine.CubeEngine.getFieldValue(CubeEngine.java:2956)
         at com.collaxa.cube.ejb.impl.InstanceManagerBean.getFieldValue(InstanceManagerBean.java:288)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.evermind.server.ejb.interceptor.joinpoint.EJBJoinPointImpl.invoke(EJBJoinPointImpl.java:35)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.JAASInterceptor$1.run(JAASInterceptor.java:31)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.security.auth.Subject.doAs(Subject.java:396)
         at com.evermind.server.ThreadState.runAs(ThreadState.java:648)
         at com.evermind.server.ejb.interceptor.system.JAASInterceptor.invoke(JAASInterceptor.java:34)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.TxRequiredInterceptor.invoke(TxRequiredInterceptor.java:50)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.interceptor.system.DMSInterceptor.invoke(DMSInterceptor.java:52)
         at com.evermind.server.ejb.interceptor.InvocationContextImpl.proceed(InvocationContextImpl.java:119)
         at com.evermind.server.ejb.InvocationContextPool.invoke(InvocationContextPool.java:55)
         at com.evermind.server.ejb.StatelessSessionEJBObject.OC4J_invokeMethod(StatelessSessionEJBObject.java:87)
         at InstanceManagerBean_RemoteProxy_4bin6i8.getFieldValue(Unknown Source)
         at com.oracle.bpel.client.InstanceHandle.getField(InstanceHandle.java:229)
         at webUI.GetTaskData.doGet(GetTaskData.java:50)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:743)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
         at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
         at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
         at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:302)
         at com.evermind.server.http.AJPRequestHandler.run(AJPRequestHandler.java:190)
         at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
         at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
         at java.lang.Thread.run(Thread.java:595)
    My code does the following calls:
    Locator locator = new Locator("default", "bpel");
    WhereCondition where = new WhereCondition(SQLDefs.CI_cikey + " = ?");
    where.setString(1, taskId);
    IInstanceHandle[] instances = locator.listInstances( where );
    IInstanceHandle instanceHandle = instances[0];
    System.out.println(instanceHandle.getTitle());
    HashMap inst = (HashMap)instanceHandle.getField("PatientRecordVariable");
    XMLElement dataXML = (XMLElement)inst.get("payload");
    String data = XMLHelper.printXML(dataXML);
    The problem is at the "getField" method. I was wondering if somebody encountered this error and know how to solve it. I think it should also be possible to access the variable directly from the database (I'm using XE) but I don't know in which table to look.
    Any help would be greatly appreciated. Thanks.
    Amir

    When I display the debugTrace message for the process instance using
    System.out.println(instanceHandle.getDebugTrace());
    it gives me this:
    <variant key="_$$process-start-time" type="long">1185481662531</variant>
    <variant key="_$$++is-sync-operation" type="boolean">false</variant>
    <variant key="++properties" id="1" ns1:type="ns2:HashMap">
    </variant>
    <variant key="_$$audit-trail-count" type="int">1</variant>
    <variant key="_$$audit-detail-count" type="int">0</variant>
    <variant key="_$$main-scope" id="2" xmlns:ns3="http://www.w3.org/2001/XMLSchema" ns1:type="ns3:string">BpPrc0.1</variant>
    <variant key="_$$operation-name" id="3" xmlns:ns4="http://www.w3.org/2001/XMLSchema" ns1:type="ns4:string">initiate</variant>
    <variant key="_$$variable-name" id="4" xmlns:ns5="http://www.w3.org/2001/XMLSchema" ns1:type="ns5:string">PatientRecordVariable</variant>
    <variant key="_$$++wi-global-table" id="5" xmlns:ns6="com.collaxa.cube.engine.core" ns1:type="ns6:WorkItemLookupTable2">
    <work-item ns1:type="ns2:WorkItem">
    <key ns1:type="ns2:WorkItemKey">
    <instance-id>70017</instance-id><node-id>BpRcv0</node-id><scope-id>BpSeq0.3</scope-id><count-id>1</count-id></key><state>closed.finalized</state></work-item><work-item ns1:type="ns2:WorkItem">
    <key ns1:type="ns2:WorkItemKey">
    <instance-id>70017</instance-id><node-id>BpAss1</node-id><scope-id>BpSeq0.3</scope-id><count-id>5</count-id></key><state>closed.finalized</state></work-item><work-item ns1:type="ns2:WorkItem">
    <key ns1:type="ns2:WorkItemKey">
    <instance-id>70017</instance-id><node-id>BpInv0</node-id><scope-id>BpSeq0.3</scope-id><count-id>4</count-id></key><state>closed.finalized</state></work-item><work-item ns1:type="ns2:WorkItem">
    <key ns1:type="ns2:WorkItemKey">
    <instance-id>70017</instance-id><node-id>BpInv1</node-id><scope-id>BpSeq0.3</scope-id><count-id>6</count-id></key><state>closed.finalized</state></work-item><work-item ns1:type="ns2:WorkItem">
    <key ns1:type="ns2:WorkItemKey">
    <instance-id>70017</instance-id><node-id>BpAss0</node-id><scope-id>BpSeq0.3</scope-id><count-id>2</count-id></key><state>closed.finalized</state></work-item><work-item ns1:type="ns2:WorkItem">
    <key ns1:type="ns2:WorkItemKey">
    <instance-id>70017</instance-id><node-id>BxExe1</node-id><scope-id>BpSeq0.3</scope-id><count-id>3</count-id></key><state>closed.finalized</state></work-item></variant>
    <variant key="_$$audit-event-count" type="int">16</variant>
    </scope><object-store></object-store></scope-context></cube-instance><work-items></work-items></debug-trace>
    There is a variant element with the attribute key whose value is "_$$variable-name" and the element has the value "PatientRecordVariable". I don't know if this is related to my problem, but if it is, I still don't understant why it could not get the data of this variable.
    Is there any way to get bpel processes' variable data from the database? I browsed the tables but I haven't found them. Hope somebody knows it.
    Amir

  • JSP Variable Scope

    Hello,
    I'm fairly new to JSP, so I apologize if this is a newbie question. I'm having a problem where it appears as though some variables I defined in the declaration area of my JSP page are shared by multiple clients. Here is a code snippet...
    <%@ page import="java.util.*" %>
    <jsp:useBean id="postSearch" scope="request" class="healthweb.PostBean" />
    <%!
    String hridErr = "";
    String emplHrid = "";
    String supvHrid = "";
    String yourHrid = "";
    boolean youAreEmpl = true;
    boolean youAreSupv = false;
    Hashtable[] empl;
    Hashtable[] you;
    Hashtable[] supv;
    %>
    <SCRIPT LANGUAGE="JavaScript">
    alert("<%= request.getParameter("yHrid") %>");
    alert("<%= youAreEmpl %>");
    </SCRIPT>
    As you can see, I'm initializing the youAreEmpl variable to true. However, if a client executes this JSP and the variable gets set to false, it seems to be false when other clients access the JSP initially.
    I'm very confused by this. Doesn't each client receive its own scope and its own instance of the object created by the JSP page?

    First off, let's start by explaining what's going on here. A JSP page is converted to a servlet via the JSP parsing servlet that initially handles the request. When you use the declaration syntax <%!...%> you are declaring members (variables, methods, etc.) that are local to the underlying servlet. Since a servlet is a multi-threaded object, all clients share the same servlet object created from the JSP page. Thus, threading issues apply to all local members of the servlet object. In other words you have to make sure the members of the servlet are thread safe.
    Many are confused by this because JSP shields you somewhat from these concerns if you stay within the confines of the predefined service() method. What I mean is this. everything you code within the <%...%> and <%=...%> delimiters is placed in the service method of the underlying servlet. This is the collection of code/objects that each client runs a unique copy of. These areas are not subject to threadding concerns/issues.
    Now, There are a number of remedies to your situation. You can remove the exclamation point from the delimeters around your variable declarations (i.e. change all <%!...%> to <%...%>), or you could add the following implements clause to your JSP page via JSP directive: implements SingleThreadModel
    Forgive me, I don't recall the exact syntax for this as I don't have any of my manuals at hand. I believe it's something like: <%@ page implements="SingleThreadModel" %> Either would solve the problem. The SingleThreadModel forces each servlet to execute in it's own thread.
    Kind Regards,
    Cliff

  • Variable scope access????

    My code:
    Code:
    onClipEvent (construct)
         function isLoaded(success)
              if (!success)
                   return (0);
              } // end if
              objArray = new Array();
              var pic = this.firstChild.attributes.pic;
              objArray.push(pic);
                              trace(objArray[0]);  // NO PROBLEM!!!
         } // End of the function
         var xmlDoc = new XML();
         xmlDoc.ignoreWhite = true;
         xmlDoc.onLoad = isLoaded;
         xmlDoc.load("pic.xml");
         trace(objArray[0]);  // UNDEFINED!?!?!?!?!?!??!?!?!?
        img_source = pic;  // BIG PROBLEM
    My pic.xml is just <?xml version="1.0" encoding="utf-8" standalone="yes" ?><items pic="img01.jpg"></items>
    What made me mad is that, objArray[0] can be accessed only in the isLoaded(). When trying to access it outside isLoaded() then it failed.
    Please help me out thanks in advance!

    Where you say the objArray is UNDEFINED it is undefined.  Those lines of code process faster than the loading of the file--they don't wait for it to finish first.  You do not want to do anything with the data being loaded until the loading is complete, which occurs in the function.
    Also, where do you actually declare the objArray variable (var objArray;) ?
    If you were to declare it inside that function, it would only have scope within that function

Maybe you are looking for