How to upgrade an array of objects?

Dear friends,

I have a number of objects stored in a table.
It seems that the table does not point to objects, but has copies.
The element of the array is only updated with the notation table [index] prop, not with the object.prop notation.

It would be possible to always use the prop table [index] notation for an update of the issues, but I want to understand why the other method does not work. And of course, there should be no copy...

var objArray = [oObject0, oObject1, oObject2];    

function oObjTpl (name, scheme, start, incr, current, decimals, items) { // 'prototype' definition
  this.Name =       name;
  this.Scheme =     scheme;                       // numermic | roman | ROMAN | text
  this.Start =      start;                        // start value
  this.Incr =       incr;                         // increment, may be a formula string
  this.Current =    current;                      // Last inserted value or item
  this.Decimals =   decimals;                     // relevant only for numeric scheme
  this.Items =      items;                        // array of list items, relevant only for text scheme
}

var items0 = ["one","two", "three", "four", "five", "six", "zz", "seven", "eight", "nine", "ten"]; 
var oObject0 = new oObjTpl ('CountingEN', 'text',     1,  1, undefined, undefined, items0);
var oObject1 = new oObjTpl ('oObject1',  'numeric', 17, -1, undefined,         0, undefined);
var oObject2 = new oObjTpl ('oObject2',  'roman',    1,  1, undefined,         0, undefined);

// replace the zz by soemething else
oObject0.Items[6] = "AAAA";       // this does not update objArray
$.writeln (objArray[0].Items);

objArray[0].Items[6] = "BBBB";    // this updates objArray
$.writeln (objArray[0].Items);

oObject0.Items[6] = "CCCC";       // update of objArray effective in next run
$.writeln (objArray[0].Items);

When you run the script 3 times, I get this console output:

one,two,three,four,five,six,zz,seven,eight,nine,ten
one,two,three,four,five,six,BBBB,seven,eight,nine,ten
one,two,three,four,five,six,BBBB,seven,eight,nine,ten
Result: undefined
one,two,three,four,five,six,CCCC,seven,eight,nine,ten
one,two,three,four,five,six,BBBB,seven,eight,nine,ten
one,two,three,four,five,six,BBBB,seven,eight,nine,ten
Result: undefined
one,two,three,four,five,six,CCCC,seven,eight,nine,ten
one,two,three,four,five,six,BBBB,seven,eight,nine,ten
one,two,three,four,five,six,BBBB,seven,eight,nine,ten
Result: undefined

Thank you Apollo, but this has not been around.

But I found that the order of definitions is crucial here. The following works as it should:

function oSeries (name, scheme, start, incr, current, decimals, items) { // 'prototype' definition
  this.Name =       name;
  this.Scheme =     scheme;                       // numermic | roman | ROMAN | text
  this.Start =      start;                        // start value
  this.Incr =       incr;                         // increment, may be a formula string
  this.Current =    current;                      // Last inserted value or item
  this.Decimals =   decimals;                     // relevant only for numeric scheme
  this.Items =      items;                        // array of list items, relevant only for text scheme
//return this;      // ahs no effect
}

var items0 = ["one","two", "three", "four", "five", "six", "zz", "seven", "eight", "nine", "ten"];
var oSeries_0 = new oSeries ('CountingEN', 'text',     1,  1, undefined, undefined, items0);
var oSeries_1 = new oSeries ('oSeries_1',  'numeric', 17, -1, undefined,         0, undefined);
var oSeries_2 = new oSeries ('oSeries_2',  'roman',    1,  1, undefined,         0, undefined);

var aSeries = [oSeries_0, oSeries_1, oSeries_2];    

var a1 = aSeries[2].Scheme;      // roman
$.writeln (a1);

// replace the zz by octogon
oSeries_0.Items[6] = "AAAA";   // this does not update aSeries
$.writeln (aSeries[0].Items);

aSeries[0].Items[6] = "BBBB";  // this updates aSeries
$.writeln (aSeries[0].Items);

oSeries_0.Items[6] = "CCCC";   // update of aSeries effective in next run
$.writeln (aSeries[0].Items);
/*
one,two,three,four,five,six,AAAA,seven,eight,nine,ten
one,two,three,four,five,six,BBBB,seven,eight,nine,ten
one,two,three,four,five,six,CCCC,seven,eight,nine,ten
*/

The order is now: implement the objects and then set up the array of objects.

Tags: Adobe FrameMaker

Similar Questions

  • FGV VI within the class method called the array of objects in a for loop

    I have an array of objects connected to the loop for I call the VI method on the object in the loop for. If the method uses/calls some VI with state/memory (such as FGV) State is shared for each method call in a loop despite the called VI is reentrant preallocated. Someone knows how to fix this?

    NVM. I found an answer:

    https://lavag.org/topic/19014-dynamic-dispatch-shared-reentrancy/

  • Power supply an array of objects returned by a remote object using AMFPHP remote procedure calls.

    Hi guys,.

    I'm working on an AIR Application that uses Flex Remoting AMFPHP, the data type returned is an array of objects that contains a shot of a url to an image on the server, how to link it to a tilelist component, so I have a list with images representing the icons and the string representing the Tilelist labels?

    We assume that the object has these fields:

    -label
    -image

    Thus, you can first pass the array to the dataProvider of the TileList and make an ItemRenderer (with a label and an image). Then, in the ItemRenderer, go to the fields with the data objects:

    ItemRenderer.mxml

  • indexOf() function for search object. < property > in an array of objects

    Hello world!
    OK, I know that the subject of this sounds a little awkward wire, with an example, it will be much clearer.
    I have a series of tables that contain strings, now named "label"; These tags can only produce only once in each table (which is therefore a 'set' of the mathematical definition of 'package', tags), but more than one table may contain a given tag (intersections of the sets are not always zero).
    I want to write a function that goes through all the tags in all tables and counties, which gives the result in a separate table called tag_counter that contains the objects of the tag. A tag object contains two fields: 'value', which is the tag itself, and 'events', which takes account of the time the tag was found.
    The function logic is simple: for each table, cycle all its labels. If the tag already exists in the tag_counter table, increment the counter 1; If not, add a new entry in the table with the given tag tag_counter. The line in bold-italics is exactly in the place of my question, because I don't know how to search within an array of objects by a property of such an object. Here is the code:

    private function harvest_tags(dt:DataTable):Array {
        var tag_counter:Array = new Array();
        
        for each(var site_feeds:Object in dt.data) {    //cycle through the Arrays
            for each(var tag:String in site_feeds.t) {  //cycle through the tags
                if(tag == '') continue;     //in case an empty tag is found, skip it
                tag = tag.replace(',', ''); //strip commas
                var i:int = tag_counter.indexOf(tag); //this needs fixing!
                if(i != -1) {
                    tag_counter[i].occurrences++;
                 }
                else {
                     tag_counter.push(new Tag(tag));
                 }
             }
         }
    
         tag_counter.sortOn("occurrences", Array.NUMERIC | Array.DESCENDING);
         return tag_counter;
    }
    

    and the class of tag definition:

    public class Tag {
            private var value:String;
            public var occurrences:Number;
            
            public function Tag(value:String) {
                this.value = value;
                this.occurrences = 1;
            }
    }
    

    Any help would be greatly appreciated.

    Andrea

    I think you want to use a hash table.  The object class is often used for this.  It is much faster than searching for an array of strings.

    private void harvest_tags(dt:DataTable):Array {}

    var tag_counter:Object = new Object();

    for each (var site_feeds:Object in dt.data) {//cycle through the berries

    for each (var: string tag in site_feeds.t) {//cycle by tags

    if(tag == '') continue;     where is an empty tag, pop it

    tag = tag.replace (',', "); Strip commas

    If (tag_counter [tag])

    tag_counter [tag] ++;

    on the other

    tag_counter [tag] = 1;

    }

    }

    var tag_array:Array = new Array();

    for {(var p:String in tag_counter)

    var tagObj:Tag = new Tag (p);

    tagObj.occurences = tag_counter [p];

    }

    Alex Harui

    Flex SDK Developer

    Adobe Systems Inc..

    Blog: http://blogs.adobe.com/aharui

  • Array of objects display BPM with JSP HOWTO

    Hello!

    Could someone please tell me, how to list the elements of an array of objects BPM with JSP? The object has attributes, and I do not know the length of the array in advance, so I would need some kinf of loop.

    I have not found any documentation or forum thread on this subject, and I'm out of ideas.

    Thanks for any help!

    Hello

    Please find the code below. Hope this code will help you

    <% int count = 0; %>

                        
         
         
         
         
         <% count++ ; %>

    Sidonie

  • How to upgrade to iOS 10

    How to upgrade to iOS 10 on Ipod touch?

    Check below link it's simple, you must have 1.2 GB of free space and only iPod touch 6th generation will support.

    Update to iOS 10 - official Apple Support

  • How to upgrade PHP

    Just try to find how to upgrade PHP on El Capitan

    You will need to do this in terminal:

    https://coolestguidesontheplanet.com/upgrade-PHP-on-OSX/

  • How to upgrade a newly purchased iWatch series 1?

    My sister bought me an iWatch, series 1, end of August. She didn't know that series 2 is coming. I have not opened the package, how to upgrade to the new series 2?

    Hello

    Apple's Standard return policy is 14 days.

    Your sister can ask Apple if they will allow an exception, but I'm afraid that no one here can tell you what Apple decides (there is a community based on the user).

    Also note that the 1 series does not refer to this first generation watch. He referred to a new Apple Watch model that has the same characteristics as the original Apple Watch, with the exception of a new dual-core processor.

  • I have an Iphone OS.  How to upgrade Itunes on my phone.

    I have an Iphone OS.  How to upgrade Itunes on my phone.

    iTunes is automatically updated with iOS updates.

    If you need to update iTunes on a computer, help you here > get the latest version of iTunes - Apple Support

  • How to upgrade my Quicktime 7 Player Quicktime 7 Pro? I am trying to upgrade the application Quicktime 7 and he continues to send me to this information page unrelated to an upgrade or buy and download option.

    I'm trying to upgrade to Quicktime Pro in the Quicktime 7 application and he continues to send me to this information page unrelated to an upgrade or buy and download option. How to upgrade my Quicktime 7 Player Quicktime 7 Pro?

    Unless you already have a QuickTime Pro key, you can't. Apple stopped selling them.

    If you do open it, choose recording in QuickTime Player 7 menu and put your key.

    (143612)

  • Can someone tell me how to upgrade the operating system on the MacPro?

    I have a MacPro1.1 which works fine, but now I can't use LightroomCC on that because the OS is no longer supported. Can someone tell me how to upgrade the operating system on the MacPro?

    Your Mac Pro 2006 supports only as high as Lion unless you use a hack.

    If you want Lion then order a code to download here:

    http://store.Apple.com/us/product/D6106Z/A/OS-x-lion

    and then use the code in the Mac App Store.

    If you need higher that the Lion then Google for the hack

  • How do upgrade the Lion to a BONE more later - I jump versions?

    I have a MacBook Pro with OS X 10.7.5 2011.  I need to upgrade to a later version of Mac OS X.  Can I make versions and upgrade directly to version 10.10 (for example)?   (On condition, of course, that my hardware meets the version requirements.)

    You can install OS X El Capitan 10.11.

    You can ignore the versions

    OS X El Capitan 10.11 system requirements

    https://support.Apple.com/kb/SP728?locale=en_US

    Check the compatibility of the application

    http://roaringapps.com/apps

    How to upgrade?

    http://www.Apple.com/OSX/how-to-upgrade/

    Save the Mac before the upgrade.

    Best.

  • How to upgrade my Safari on my Mac?

    How to upgrade my Safari on my Mac laptop?

    By upgrading the version on your Mac OSX.

    See if your Mac takes care of El Capitan.

    http://www.Apple.com/OSX/how-to-upgrade/?CID=WWA-us-KWG-Mac

    If this is not the case, what Mac model you have?

  • How to upgrade an iphone 4 that will not be updated

    How to upgrade an iphone 4 if it used to let me update

    An iPhone 4 cannot be updated past iOS 7.1.2.

    (143226)

  • How to upgrade iso 4.1.2 new vertion os ISO

    How to upgrade iso 4.1.2 new ISO os version

    An iPhone 3G cannot be updated past 4.2.1.

    (142941)

Maybe you are looking for

  • Who needs for new adapter disp wddm drivers.

    First of all, I have an old HP pavilion a730n with a p4 3 GHz processor and 1.5 GB of ram worked with Xp, but I switched to Win7 Home Prem had find the compatible drivers. Finally got some help other people and things works better, but still had to s

  • Cannot copy files to the CD/DVD to the computer.

    Original title: new problem - cannot use Cd/DVD to open files I can do now? I tried to re - install My Documents to my computer. Now, my computer has a CD FULL of Documents recorded, but does not open what can I do? Need repair help

  • Cannot install updated, get the error code 643

    Update Vista is a failure.  Get the error code 643

  • Connection Remote Desktop - between two Windows XP-based computers

    Setup: desktop win xp pro laptop win xp family, linksys router. broadband connected to the router, computer connected to the router, computer desktop laptop wireless to the router. can use mobile to contrl desktop network domestic by DRC opening and

  • Windows 7 Pro will not restart if printer on.

    Hello When you click Restart, Windows 7 Pro will not reboot with a printer hp (L7680 or C309a) turned on.  The screen remains right on "Starting Windows".  Windows continues to load after that whatever printer is turned on. This problem just started.