Ordered arrays

Hey guys I hate to bother you my first question so soon, but I've set up a 2d ordered array, and while my delete and search methods work okay, my display/insertion methods have to be missing something, or perhaps I've used too much information. Don't get me wrong, the 2d array in my driver is in ascending order like it should be, but the elements are not in the right coordinates. The only one that is placed right is 0,0. Everything else just shows up in 1,1 or 2,2, or 3,3, or 4,4, instead of where they are supposed to go. Any hints would be greatly appreciated.
  class ArrayBinary                              
      private int[][] a;          // ref to array a
      private int nElems;          // number of data items
       public ArrayBinary (int x, int y)
         a = new int[x][y];               // creates array
         nElems = 0;
       public int size()
         return nElems;                         
       public int find(int searchKey)
         int lowerBound = 0;
         int upperBound = nElems-1;
         int middle;
         while(true)
            middle = (lowerBound + upperBound) / 2;
            if(a[middle][middle] == searchKey)
               return middle;                                                  //found it
            else if (lowerBound > upperBound)
               return nElems;                                        // can't find it
            else
               if (a[middle][middle] < searchKey)
                  lowerBound = middle + 1;                         // its in upper half
               else
                  upperBound = middle - 1;                         // its in lower half
         }               // ends find
       public void insert (int x, int y, int value)          // puts element into array
         int i;                                                                      
         for (i =0; i < nElems; i++)               // finds where it goes
            if(a[i] > value)
break;
for (int j = nElems; j > i; j--)
a[j][j] = a[j-1][j-1];               // moves bigger ones up
a[i][i] = value;                         // inser it
nElems++;                                   // increment size
public boolean delete(int value)
int i = find(value);
if(i==nElems)
return false;                         // can't find it
else
for(int j = i; j < nElems; j++)
a[j][j] = a[j+1][j+1];                         // found it
nElems--;                                   // decrement size
return true;
}          // end delete
public void display()                         // displays array contents
for (int i = 0; i < a.length; i++)
for (int j = 0; j < a[i].length; j++)
System.out.print(a[i][j] + " ");
System.out.println("");
Edited by: Leilong on Sep 4, 2008 8:11 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

just a note: you have some if's and for's without curly braces
this is VERY BAD practice and will get you into trouble, especially if you're a noob

Similar Messages

  • Order array by object variable

    Hello !
    I have an array which I'm looping through to get variables(as text) to display in dynamic text fields..
    If possible I would like to sort the array into numeric order using "sTabArray[i].sHour". A variable of each of the array items..
    Is there a way I can do this ? Maybe create a new array from the original one and then use that ??
    for(i = 0; i < sTabArray.length; i++) {
        var sMin:String = sTabArray[i].sMin;
        var fMin:String = sTabArray[i].fMin;
        var table_number:String = sTabArray[i].table_number;
        var salle_number:String = sTabArray[i].salle_number;
        printBox["horaires" + i].text = sTabArray[i].sHour + ":" + sMin + " à " + sTabArray[i].fHour + ":" + fMin;
        printBox["evenement" + i].text = sTabArray[i].titre;
        printBox["salle" + i].text = salle_number;
        printBox["table_no" + i].text = table_number;
    Many thanks in advance for you help
    Martin

    sortOn
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/Array.html#sortOn%28%29

  • Help plz regarding array and DB

    hi ,
    i have a problem regarding sorting.
    I have 1 million records in my DB table.
    When i open my swing application i sort the records in table [ORDER BY col1,col3,col4] like that and want that order record ids .
    upto here no problem.i am getting the ids in array and in my swing application when i go next i get from arrray the next record.
    but the problem is since the volume of the table is large if any addition r deletion to the table is not reflecting in the sorted order array.
    i can simply again call the database and sort it an update the error.but it proved very insufficent way.
    so i am looking something to optmise the sorting.
    i got an idea like using view .but i am looking anybody knows any workaround alogrithm for this.
    sree

    Here is an example taken from the ResultSet API Doc's. Note the constant type of "TYPE_SCROLL_SENSITIVE" for the type of ResultSet. Is this what you are using? (I have not tried this, but it is the solution that is put forth in my books and documents.)
           Statement stmt = con.createStatement(
                                          ResultSet.TYPE_SCROLL_SENSITIVE,
                                          ResultSet.CONCUR_UPDATABLE);
           ResultSet rs = stmt.executeQuery("SELECT a, b FROM TABLE2");
           // rs will be scrollable, will not show changes made by others,
           // and will be updatable

  • Easy question array

    Hello experts,
    i have an easy question. I need to store data in a 1D array so that the first data is written in the place of index 1 the second in index 2 aso.  I've tried it but somehow either i only had the last data in all indexes or only the last data in the last index. I am posting you a vi. I know where i should change it but i need a small idea oder change in the vi.
    Thank u for your help.

    Attachments:
    array_shift.vi ‏7 KB

    Please save your VI in ver 8.2 and then paste it on the forum so that i may help in making it into what you want. Without seeing the VI i am guessing that you have elements or 1-D arrays that you want to append into a single array.
    Its simple whether its the elements that you want to build into 1-d array or arrays that you want to make into a single array. Just use the build array function. Connect the input wires to the element and you'll have your 1-D array, provided you havent unchecked Concatenate Inputs in which case you will have a higher order array instead.
    Anyways kindly paste it in changed format so that i may help.
    Regards
    Asad Tirmizi
    Design Engineer
    Institute of Avionics and Aeronautics
    " Its never too late to be, what u want to be"
    Using LabVIEW 8.2

  • Moving arrays around

    Hi,
    Ive recently been messing around with some array stuff (only recently started Learning java)
    And ive written a program that takes members of a array and moves the first to the end and then moves the rest up one space so in my array of 4 members the member in 0 is moved to 3 and then all the other members are moved up one so 3 becomes 2 and so on.
    Now i then went back to try and do it the other way round move the member in slot 3 to 0 and then the others move back but this time ive run into some problems.
    Heres the original code i wrote to move 0 to 3:
    class Band
         public static void main(String[] args)
              String band[ ] = {"John", "Paul", "George", "Ringo"};
              System.out.println("Original Order");
              //Prints out the array to test its working.
              for (int i = 0; i < band.length; i++)
                   System.out.println(band);
              //Changes the order of the array so that John is last.
              String s = band[0];
              for (int b = 0; b < band.length -1; b++)
                   band[b] = band[b+1];
              band[band.length - 1] = s;
              System.out.println(" ");
              System.out.println("New Order");
              //Prints out the new ordered array to test its working.
              for (int n = 0; n < band.length; n++)
                   System.out.println(band[n]);
    Ok so that just outputs the following:
    Original Order:
    John
    Paul
    George
    Ringo
    1st New Order:
    Paul
    George
    Ringo
    John
    Now heres the new version to move ringo to johns position and the others down one:
    class Band
         public static void main(String[] args)
              String band[ ] = {"John", "Paul", "George", "Ringo"};
              System.out.println("Original Order");
              //Prints out the array to test its working.
              for (int i = 0; i < band.length; i++)
                   System.out.println(band);
              //Changes the order of the array so that Ringo is first.
              String r = band[3];
              for (int h = 3; h < band.length -1; h--)
                   band[h] = band[h-1];
              band[band.length -4] = r;
              System.out.println(" ");
              System.out.println("2nd New Order");
              //Prints out the new ordered array to test its working.
              for (int m = 0; m < band.length; m++)
                   System.out.println(band[m]);
    Now when i run that this is the part where it all goes wrong and the output is then:
    Original Order:
    John
    Paul
    George
    Ringo
    1st New Order:
    Ringo
    Paul
    George
    Ringo
    As you can see from that it moves ringo to johns space but the rest dont move.
    Can anyone give me a hand in figuring this out as ive spent nearly a whole day working on it for what i think is going to be a simple answer.
    Cheers in advance LordOfGood

    You should concider using the statndard Collections in this case ArrayList
            List band = new ArrayList(Arrays.asList(new String[]{"John", "Paul", "George", "Ringo"}));
            System.out.println("Original Order");
            System.out.println(band);
            //Changes the order of the array so that Ringo is first.
            String ringo = (String) band.remove(3);
            List band2 = new ArrayList(4);
            band2.add(ringo);
            band2.addAll(band);
            System.out.println("\n2nd New Order");
            System.out.println(band2);

  • How to create a nested hierarchy of layers in Acrobat X

    After researching on line for a few days it appears that AutoCAD 2012 64 bit no longer supports PDFMaker.  In the old PDFMaker it would appear that I could select AutoCAD layers to make a layer groups or nested hierarchy.  I want create something like the first page of this http://floridadisaster.org/publicmapping/HELP.pdf  Multiple groups with nested sublayers to several levels.  With no luck on the exporting end I wonder if there is an Adobe product that can do this.  Illustrator creates the same structure and then only exports the top layer.  InDesign doesn't allow for layer groups or nested layers unless it has the DTP plugin, but then it only exports the top level layers.  Any ideas?  I have yet to find a product other than ArcGIS which is overkill for just the creation of a layer/sublayer hiearchy and expensive.
    Thanks,
    Josh

    Actually, the "tree" you see on the right panel isn't a layers tree at all. OCGs (aka "layers") in a PDF file are in a simple 1-level stack, but you can define groups of layers, which Acrobat displays using the tree style. While there's no grouping or ungrouping tool in the user interface in Acrobat, you can do it via JavaScript by writing arrays of arrays into the doc.OCGOrder object. To quote the Acrobat SDK:
    The simplest order array is a flat array of OCG objects. In this case, the listed OCGs are displayed in the UI as a flat list in the same order. If a subarray is present in the order array and the first element of the array is a string, the string will be listed with the rest of the array nested underneath it. If the first element of the array is not a string, the entire array will appear nested underneath the OCG preceding the subarray.

  • SQL query does not give me correct search results

    I have the code below for a search box with some fields input into the query.
    I want to be able to select all and only give results for a match of all the selected results.
    I know I have to use AND in the query.
    But it is giving me other cars in the results.
    So if I choose Alfa Romeo a BMW will be listed in the results too.
    $query = array();
    if(!empty($_GET[c]))
        $query[] = "cars_listings.CategoryID = '$_GET[c]' ";
    if(!empty($_GET[AgentID]))
        $query[] = "cars_listings.AgentID = '$_GET[AgentID]' ";
    if(!empty($_GET[search_country]))
        $query[] = "cars_agents.country = '$_GET[search_country]' ";
    if(!empty($_GET[search_state]))
        $query[] = "cars_agents.state = '$_GET[search_state]' ";
    if(!empty($_GET[search_city]))
        $query[] = "cars_agents.city = '$_GET[search_city]' ";
    //if(!empty($_GET[postcode]))
    //    $query[] = "cars_agents.postcode = '$_GET[postcode]' ";
    if(!empty($_GET[min]))
        $query[] = "cars_listings.price >= '$_GET[min]' ";
    if(!empty($_GET[max]))
        $query[] = "cars_listings.price <= '$_GET[max]' ";
    if(!empty($_GET[year1]))
        $query[] = "cars_listings.VehicleYear >= '$_GET[year1]' ";
    if(!empty($_GET[year2]))
        $query[] = "cars_listings.VehicleYear <= '$_GET[year2]' ";
    if(!empty($_GET[before]))
        $MyDate = strtotime("-$_GET[before]");
        $query[] = "cars_listings.DateAdded >= '$MyDate' ";
    if(!empty($_GET[cars]))
        $query[] = "cars_listings.VehicleMake <= '$_GET[cars]' ";
    if(!empty($query))
        $MyQuery = implode(" and ", $query);
        $MyQuery = " and ".$MyQuery;
    //////////        order by
    $order = array(); 
    if(!empty($_GET[orderby]))
        $MyOrder = explode("|", $_GET[orderby]); 
        while(list(,$ov) = each($MyOrder))
            if($ov == "DateAdded")
                $order[] = " cars_listings.DateAdded desc ";
            if($ov == "Price")
                $order[] = " cars_listings.Price asc ";
            if($ov == "address")
                $order[] = " cars_agents.address asc ";
    else
        if(!empty($_GET[p]))
            $order[] = " cars_listings.Price asc ";
        if(!empty($_GET[r]))
            $order[] = " cars_listings.mileage asc ";
        if(!empty($_GET[vehicle]))
            $order[] = " cars_vehicle.VehicleName ";
    if(count($order) > '0')
        $MyOrder = implode(", ", $order); 
    if(empty($MyOrder))
        $MyOrder = " order by cars_agents.PriorityLevel desc, cars_listings.DateAdded desc";
    else
        $MyOrder = " order by cars_agents.PriorityLevel desc, $MyOrder, cars_listings.DateAdded desc";
    if(!empty($_GET[Start]))
        $Start = $_GET[Start];
    else
        $Start = '0';
    $ByPage = '20';
    $pcode = $_GET[postcode];
    $q1 = "select * from cars_listings, cars_agents, cars_priority, cars_vehicle where cars_listings.AgentID = cars_agents.AgentID and cars_agents.PriorityLevel = cars_priority.PriorityLevel and cars_agents.AccountStatus = 'active' and cars_listings.VehicleMake = cars_vehicle.VehicleID $MyQuery $MyOrder limit $Start, $ByPage "; 
    I hope that is clear to you.
    This code was given to me by my client to amend with a postcode function.
    Problem is the postcode database table always outputs 3miles

    SELECT * FROM LFBK
                     INTO TABLE <ITABL>
                     FOR ALL ENTRIES IN IT_TIBAN
                     WHERE BANKN EQ IT_TIBAN-BANKN.
    As the Data element of TIBAN-BANKN and LFBK-BANKN is different, i afraid FOR ALL ENTRIES will also not work.. any way try or else compare with other keys like....
    SELECT * FROM LFBK
                     INTO TABLE <ITABL>
                     FOR ALL ENTRIES IN IT_TIBAN
                     WHERE BANKS eq IT_TIBAN-BANKS
                     AND       BANKL eq IT_TIBAN-BANKL
                     AND       BKNOT eq IT_TIBAN-BKNOT.
    If you list your requirement clear, then can help with create query with all tables...
    Thanks & Regards,
    SUJI.

  • Unable to access Mojikumi settings set by InDesign using jsx DOM

    Hello all,
    I am using Japanese InDesign version 7.5 on windows 7. I've set paragraph indent through mojikumi settings and trying to acces it through jsx object model. The following is what I did:
    I have created a new Mojikumi set based on default LINE_END_ALL_ONE_HALF_EM_ENUM. All I have changed in new set is "Paragraph Mojikumi Indent" from none to 1 char. I want to access this setting from java script using its object model. I've tried the method paragraphObject.mojikumi.overrideMojikumiAkiList which seems to be the related method to access the customized settings. The output of the function I'm getting is a big array:
    2,23,false,1,1,1,0,false,3,23,false,1,1,1,0,false,4,23,false,1,1,1,0,false,5,23,false,1,1, 1,0,false,6,23,false,1,1,1,0,false,21,23,false,1,1,1,0,false,7,23,false,1,1,1,0,false,8,23 ,false,1,1,1,0,false,9,23,false,1,1,1,0,false,10,23,false,1,1,1,0,false,11,23,false
    ,1,1,1,0,false,12,23,false,1,1,1,0,false,24,23,false,1,1,1,0,false,25,23,false,1,1,1,0,fal se,18,23,false,1,1,1,0,false,33,23,false,1,1,1,0,false,28,23,false,1,1,1,0,false,29,23,fal se,1,1,1,0,false,30,23,false,1,1,1,0,false,31,23,false,1,1,1,0,false,32,23,false,1,1,1,0
    ,false,1,23,false,1,1,1,0,false,26,23,false,1,1,1,0,false,27,23,false,1,1,1,0,false
    Of these values, how can I deterministically find the one that corresponds to paragraph mojikumi indent? Also the size of array seems to be changing as we add or change override values for diefferent mojikumi sets. So its definitely not based on array index.
    API description says:
    overrideMojikumiAkiList
    Array of
    akiDoesNotFloat:Boolean
    compressionPriority:Short Integer
    desired:Real
    maximum:Real
    minimum:Real
    Ordered array containing targetMojikumiClass:Short Integer
    sideIsAfterTarget:Boolean
    sideMojikumiClass:Short Integer
    r/w
    The mojikumi overrides for aki. Can return: Ordered array containing targetMojikumiClass:Short Integer, sideMojikumiClass:Short Integer, sideIsAfterTarget:Boolean, minimum:Real, desired:Real, maximum:Real, compressionPriority:Short Integer, akiDoesNotFloat:Boolean.
    Any pointers to help links or any insights on how to  decode the above array deterministically for all mojikumi sets will be of great help to me.
    Thanks,
    Srikanth

    Hi
    here is link when..
    I get Diff custom setting and default setting
    http://www.milligramme.cc/wp/archives/537
    and get applied mojikumi sets in most front document
    http://www.milligramme.cc/wp/archives/3368
    I hope you will find it helpful
    thanks
    mg.

  • HTMLClient: Sum of products in child records

    Hi All,
    Scene:
    I have a table called Jobs with a field called JobTotal. I have another table called Products which has fields - Description and Price. I have a third table to enable a multiple/multiple relationship called
    JobProductMappings with multiple:1 links to Products and multiple:0/1 to Jobs.
    Problem:
    I would like to display the total cost of the job of the products linked to the job. I've been having a few issues working this out so if anyone has any suggestions they would be welcomed :)
    Cheers,
    Adam

    Computed properties in the LS HTML client have been discussed many times here on the forums, and there are several approaches.  The previous post mentioned probably the most helpful treatment on the subject found at Michael's website (although the code
    that is listed is not useful for the HTML client and can be ignored):
    http://lightswitchhelpwebsite.com/Blog/tabid/61/EntryId/185/Computed-Properties-With-the-LightSwitch-HTML-Client.aspx
    HTML client computed properties that involve data across relationships and tables, such as yours, are typically more involved to code. Michael has shown how to manage the difficulties using WCF RIA services.  Using the Flower Shop project as a base,
    I'll point out a third way to do the same thing as a RIA class, or at least the essential part, namely retrieving an anonymous type as a projection at the server, using JayData.
    First, starting the the ComputedValuesHTMLClient2013 project, NuGet package manager is used to add JayData to the project.
    Next, using the included JaySvcUtil.exe program, the entity data model file is auto-generated. Both JayData.js and the generated model JS file are added to the default.htm script list.
    In the Main Screen, a global variable to hold the FlowerShop database is created and the JayData connection to the LightSwitch database is initialized:
    var FlowerShopDb = window.FlowerShopDb || {};
    myapp.Main.created = function(screen) {
    // Write code here.
    FlowerShopDb = new LightSwitchApplication.ApplicationData({
    name: 'oData',
    oDataServiceHost: '/ApplicationData.svc'
    $.when(FlowerShopDb.onReady())
    .then(function() {
    console.log(FlowerShopDb);
    On the BrowseFlowerShopOrders Screen, a custom control named "Total Order Price" will be added to the Flower Shop Orders list, right above Order Date.  In the _render method, there is:
    myapp.BrowseFlowerShopOrders.TotalOrderPrice_render = function (element, contentItem) {
    // Write code here.
    element.innerHTML = '<div id="TotalOrderPriceDiv"></div>';
    Now for JayData to make short shrift of this. In the Flower Shop Order (item) Columns Layout--the row template control, the following will go in the _postRender method:
    myapp.BrowseFlowerShopOrders.RowTemplate_postRender = function(element, contentItem) {
    // Write code here.
    FlowerShopDb.FlowerShopOrderDetails
    .filter("it.OrderDetail_Order === this.OrderId", { OrderId: contentItem.data.Id })
    .map(function(order) {
    return {
    ProductPrice: order.FlowerShopProduct.Price,
    Quantity: order.Quantity
    .toArray(function(orders) {
    var orderTotal = 0;
    orders.forEach(function(o) {
    orderTotal += o.ProductPrice * o.Quantity;
    $('#TotalOrderPriceDiv', element).text('$' + orderTotal);
    Briefly, the Flower Shop Order Id is used as the filter to pull up the corresponding FlowerShopOrderDetail (via EF's OrderDetail_Order navigation property). The anonymous projection pulls up the corresponding price and quantity of the Flower Order details (again
    across navigation properties at the server), and stores it in an array orders. Next, it iterates through the orders array, multiplying price and quantity and aggregating to a variable
    orderTotal.  Finally, once the server has returned all the values and calculations are complete, the result is displayed in the Total Order Price custom control field.

  • [CS4 JS] Live Preflight

    Hi,
    The following is part of script which checks to see if there are any errors in the Live Preflight before continuing with a PDF export.
    var myPreflight = app.preflightProcesses[0];
    var myReport = myPreflight.processResults;
    myReport = myReport.replace(/\s+$/,"");
    if (myReport == "None")
    My problem is that this script doesn't distinguish between the Preflight for the current document and that for any other document that may be open. I assume it is using the FIRST Preflight process created which will not always be for the current document.
    Is there a way to reference the Preflight for the current document only? Searching for "Preflight" in the Object Model Viewer in ExtendScript Toolkit bring up No Results.
    Thanks,
    Skempy

    var myPreflight = app.preflightProcesses[0];
    var myReport = myPreflight.processResults;
    myReport = myReport.replace(/\s+$/,"");
    if (myReport == "None")
    My problem is that this script doesn't distinguish between the Preflight for the current document and that for any other document that may be open. I assume it is using the FIRST Preflight process created which will not always be for the current document.
    Is there a way to reference the Preflight for the current document only? Searching for "Preflight" in the Object Model Viewer in ExtendScript Toolkit bring up No Results.
    maybe you should check this "array":
    Property AggregatedResults As Variant
        read-only
        Member of InDesign.PreflightProcess
        The aggregated results found by the process. Type: Ordered array containing DocumentName:String, ProfileName:String, Results:Array of Ordered array containing ParentNodeID:Long Integer, ErrorName:String, PageNumber:String, ErrorInfo:String, ErrorDetail:Array of Ordered array containing Label:String, Description:String
    or maybe you should set PreflightScope - to your Document - in PreflightOptions:
    Property PreflightScope As Variant
        Member of InDesign.PreflightOption
        The pages or documents to preflight, specified either as an enumeration or a string. To specify a range, separate page numbers in the string with a hyphen (-). To specify separate pages, separate page numbers in the string with a comma (,). Type: idPreflightScopeOptions enumerator or String
    robin
    www.adobescripts.co.uk

  • [CS4 JS] Test for Preflight Errors

    Hi,
    Is it possible to test for preflight errors. If so, how?
    I want to allow export of an EPS only if an embedded preflight profile shows no errors.
    Thanks
    Simon Kemp

    var myPreflight = app.preflightProcesses[0];
    var myReport = myPreflight.processResults;
    myReport = myReport.replace(/\s+$/,"");
    if (myReport == "None")
    My problem is that this script doesn't distinguish between the Preflight for the current document and that for any other document that may be open. I assume it is using the FIRST Preflight process created which will not always be for the current document.
    Is there a way to reference the Preflight for the current document only? Searching for "Preflight" in the Object Model Viewer in ExtendScript Toolkit bring up No Results.
    maybe you should check this "array":
    Property AggregatedResults As Variant
        read-only
        Member of InDesign.PreflightProcess
        The aggregated results found by the process. Type: Ordered array containing DocumentName:String, ProfileName:String, Results:Array of Ordered array containing ParentNodeID:Long Integer, ErrorName:String, PageNumber:String, ErrorInfo:String, ErrorDetail:Array of Ordered array containing Label:String, Description:String
    or maybe you should set PreflightScope - to your Document - in PreflightOptions:
    Property PreflightScope As Variant
        Member of InDesign.PreflightOption
        The pages or documents to preflight, specified either as an enumeration or a string. To specify a range, separate page numbers in the string with a hyphen (-). To specify separate pages, separate page numbers in the string with a comma (,). Type: idPreflightScopeOptions enumerator or String
    robin
    www.adobescripts.co.uk

  • API for tag parameters?

    Hi,<br /><br />Does anyone know the appropriate API call for embedding elements _within_ a tag? Versions/stVer:event is an appropriate example where this occurs. It should look something like this:<br /><br />   <xmpMM:Versions><br />     <rdf:Seq><br />       <rdf:li rdf:parseType='Resource'><br />         <stVer:event <br />          stEvt:action='version 4 created' <br />          stEvt:parameters='some helpful info' <br />          stEvt:softwareAgent='Adobe InDesign 2.0 for Windows' <br />          stEvt:when='2001-08-09T12:45:39Z'/><br />       </rdf:li><br />     </rdf:Seq><br />   </xmpMM:Versions><br /><br />but mine turn out something like this...<br /><br /><xapMM:Versions>                                                                        <br />   <rdf:Seq>                                                                              <br />    <rdf:li rdf:parseType='Resource'>                                                     <br />     <xapMM:event rdf:parseType='Resource'>                                               <br />      <stEvt:action>version 4 created</stEvt:action>                                      <br />      <stEvt:instanceID>3</stEvt:instanceID>                                              <br />      <stEvt:parameters>some helpful info</stEvt:parameters>                            <br />      <stEvt:softwareAgent>Adobe InDesign 2.0 for Windows</stEvt:softwareAgent>      <br />      <stEvt:when>2004-02-06T09:47:12Z</stEvt:when>                                       <br />     </xapMM:event>                                                                       <br />    </rdf:li>                                                                             <br />   </rdf:Seq>                                                                             <br />  </xapMM:Versions>                       <br /><br />Any guidance would be appreciated. <br /><br />Thanks again<br />dave

    Your second case is the correct structure, you just have the namespace wrong for the event field. It should look like this:<br /><br /><xapMM:Versions> <br />   <rdf:Seq> <br />    <rdf:li rdf:parseType='Resource'> <br />     <stVer:event rdf:parseType='Resource'> <br />      <stEvt:action>version 4 created</stEvt:action> <br />      <stEvt:instanceID>3</stEvt:instanceID> <br />      <stEvt:parameters>some helpful info</stEvt:parameters> <br />      <stEvt:softwareAgent>Adobe InDesign 2.0 for Windows</stEvt:softwareAgent> <br />      <stEvt:when>2004-02-06T09:47:12Z</stEvt:when> <br />     </stVer:event> <br />    </rdf:li> <br />   </rdf:Seq> <br />  </xapMM:Versions><br /><br />xapMM:Versions is an ordered array of Version structs. The <rdf:Seq> says xapMM:Versions is an ordered array. The <rdf:li rdf:parseType='Resource'> says the array item is a struct. stVer:event is one of the fields in a Version struct, stVer:event is itself a struct and  <stVer:event rdf:parseType='Resource'> says this. The stEvt:* elements are the fields of the stVer:event struct.

  • Acrobat Pro Calculating form fields lose functionality after enabling document for Reader

    I have a problem that continues to come up increasingly. I thought I had found a work-around on some forums, but it is still causing trouble. Im hoping you can answer the question.
    I am creating a form that requires simple calculations (sum and add). I can get these calculations to work just fine. However, as soon as I enable the document for Adobe Reader, the form seems to get amnesia. It loses the ability to calculate. When I go into the fields again to look at them, they still show that they are supposed to calculate, but arent working. I have to clear the calculations and completely reset them all in order to get them to function again, but as soon as I save this enabled doc, it loses its functionality all over again.
    Frustrating.
    I did find a work-around on a forum, but have only gotten it to work once. It had something to do with closing and saving the document, then reopening it before entering the calculations.
    Is there a clear-cut solution to this problem? The forums were rife with people experiencing the same frustrations.
    Thanks ahead of time for your assistance.

    Nathan,
    It's fairly straighforward to set up a custom validation script for this, but it might not be immediately obvious how to do it. I'll use your form as an example. In it, you have a number of rows with a Quantity field where the user enters how many items are needed, a Price field that has as its default value the price for the item, and a Total field which is a calculated field and should be the product of the Quantity and Price fields. The only variable in the calculation is the value of the Quantity field, so this will be easy.
    The Validate event of a field gets triggered when the field value is committed. This happens when the user enters a value and presses Enter, Tab, clicks outside of the field, etc. What the script should do is take the value the user entered, multiply it by the value that's in the Price field, and set the value of the Total field. The script could look something like:
    (function () {
        // Get the value of this field, as a number
        var qty = +event.value;
        // Get the value of the Price field, as a number
        var price = +getField("PRICE.0").value;
        // Calculate the total
        var total = qty * price;
        // Set the value of the Total field if not zero,
        // otherwise, blank it out
        getField("TTL.0").value = total ? total : "";
    What you really should do, however, is set up a document-level JavaScript (Advanced > Document Processing > Document JavaScripts...) that contains a function you can call from the QTY field of each row. The function will determine which row should be affected based on the field name that triggers it. Something like:
    function calcTotal() {
        // Get the row number from the field name
        // of the field that called this function
        var row = event.target.name.split(".").pop();
        // Get the value of the field that called this function, as a number
        var qty = +event.value;
        // Get the value of the Price field, as a number
        var price = +getField("PRICE." + row).value;
        // Calculate the total
        var total = qty * price;
        // Set the value of the Total field if not zero,
        // otherwise, blank it out
        getField("TTL." + row).value = total ? total : "";
    Than all you have to place as the custom Validate script of each of your QTY fields is the following:
    calcTotal();
    Also, make sure that you remove any calculations that you've set up on the Calculate tab of each TOTAL field. Now that the total fields do not rely on automatic calculations, it does not matter that the document is missing its field calculation order array, though this bug REALLY needs to be fixed. You should consider reporting it to Adobe. I will report it too.
    Note that this code assumes the QTY and PRICE fields are numeric fields, meaning they will either be blank or contain a valid number. You've ensured this by setting up each with a Format category of Number.
    George

  • Producer consumer puzzle

    Hello All,
    I have two arrays with me
    Producer array
    P1,P2,P3,P4,P5...Pn
    Consumer array
    C1,C2,C3,C4,C5...Cn
    Let us take arrays having 5 elements
    P1 P2 P3 P4 P5
    1 2 3 4 5
    C1 C2 C3 C4 C5
    5 4 3 2 1
    The output should be
    Result1
    (P1,C5),(P2,C4),(P3,C3),(P4,C2),(P5,C1).
    Results 2
    (P1,C5),(P2,C4),(P3,C4),(P4,C3),(P5,C2)
    Result N
    When forming such combinations the only criteria that needs to be kept in mind is we can never pair (Pi,Ci) when Pi<Ci.
    How do we generate all such combinations as shown above
    Thanks.
    Regards.
    NP

    Hi there,
    This is what I had in mind.
    Thanks.
    Regards.
    NP
    package mypackage1;
    import java.io.*;
    import java.util.*;
    class Class4
    public static int[] interchange(int t[],int count)
    int len = count;
    int hlen = len / 2;
    int temp;
    int t1[]=new int[100];
    t1=t;
    for( int i = 0; i <= hlen; i++)
    temp = t1;
    t1 = t1[len - 1 - i];
    t1[len - 1 - i] = temp;
    return(t1);
    public static void search(int a1,int a2,int c1[],int c2[],int count)
    //System.out.println("I am here");
    int pos_p;
    int pos_c;
    int i;
    for(i=0;i<count;i++)
    if(a1==c1 )
    System.out.println("This Producer i =" + i);
    for(i=0;i<count;i++)
    if(a2==c1)
    System.out.print("Matches with Consumer i =" + i);
    public static void main(String [] arg) throws Exception
    int dup_p[]=new int[50]; //Contains Producer array
    int dup_c[]=new int[50]; //Contains Consumer array
    int p[]=new int[50]; //Contains sorted Producer array
    int c[]=new int[50]; //Contains sorted Consumer array
    int i,j;
    int k=0; //Index for producer array
    int l=0; //Index for consumer array
    int m=0; //Index to keep track of count of elements
    BufferedReader console= new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Enter the number of resources you want to input");
    String input=console.readLine();
    int count=Integer.parseInt(input);
    System.out.println(count);
    System.out.println("Enter the resource values for producer array");
    for(i=0;i<count;i++)
    String var_input=console.readLine();
    p=Integer.parseInt(var_input);
    System.out.println("Reading done\n");
    System.out.println("Enter the resource values for consumer array");
    for(i=0;i<count;i++)
    String var_input1=console.readLine();
    c=Integer.parseInt(var_input1);
    //Making copies of the original array
    for(i=0;i<count;i++)
    dup_c=p;
    dup_c=c;
    //Sorting in Producer array in Descening order
    Arrays.sort(p,0,count);
    p=interchange(p,count);
    //Sorting in Producer array in Ascending order
    Arrays.sort(c,0,count);
    c=interchange(c,count);
    while(m<count)
    if(p[k]>=c[l])
    //search(p[k],c[l],dup_p,dup_c,count);
    System.out.println("Producer p="+ k + "Consumer c=" + l);
    k++;
    l++;
    else
    l++;
    m++;

  • Script to add description and keywords to files from text file

    Can anyone write something up for me? I will admit I cannot do it myself, I do not know Javascript.
    I need to add keywords and a description to 1000's of images. I have a text file formatted as such for each 100 images. The script would need to ask for an input file (or I can hardcode the path into the script) and then apply to the current folder of images shown in bridge.
    Text file example:
    1000 - Bright Sunset Over City. (sun;city;sky;mountain;) .
    1001 - Dawn Behind Mountain And Lake. (sun;mountain;water;sky;) .
    1002 - Bright Red Sunset, Light Edged Clouds. (sun;sky;tree;clouds;) .
    1003 - Tree Framing Sunset Over Bay. (tree;sun;lake;bay;) .
    1004 - Sun Behind Gull On Pilings. (seagull;sun;sea;pilings;) .
    images are named 1000.tif, 1001.tif, 1002.tif etc
    Running on a Mac with CS3 and CS4.
    Thanks,
    Chris

    Hi Paul,
    This is nice example, but your script incorrectly sets both dc:description and dc:subject as ordered arrays. Description should be an alt-text type property, and subject is an unordered array (or 'bag'). Some software might not tolerate the incorrect XMP data types.
    Here's an example showing the wrong and write way to set these two properties using the XMP Script API:
    // load the library
    if (ExternalObject.AdobeXMPScript == undefined) {
        ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
    var Desc = "Test Description";
    var Keys = ["One","Two","Three"];
    // The wrong way to set the Description. and Keywords...
    var bogusXmp = new XMPMeta();
    bogusXmp.appendArrayItem(XMPConst.NS_DC, "description", Desc, 0,XMPConst.ARRAY_IS_ORDERED);
    for(var s in Keys){
          bogusXmp.appendArrayItem(XMPConst.NS_DC, "subject", Keys[s], 0,XMPConst.ARRAY_IS_ORDERED);
    $.writeln( bogusXmp.dumpObject() );
    // The correct way to set the Description and Keywords
    var correctXmp = new XMPMeta();
    correctXmp.setLocalizedText( XMPConst.NS_DC, "description", null, "x-default", Desc );
    for(var s in Keys){
          correctXmp.appendArrayItem(XMPConst.NS_DC, "subject", Keys[s], 0,XMPConst.PROP_IS_ARRAY);
    $.writeln( correctXmp.dumpObject() );
    Thanks,
    David

Maybe you are looking for

  • Select Expert - Formula : Some clarifications

    Hi, Can anyone explain the below formula in Select Expert: IF {?param} = "AAA" THEN {Command.CD} = "ALL" ELSE IF {?param} = "BBB" THEN NOT({Command.CD} = "BALL") ELSE true My doubts are: 1) This formula will be executed after the query in the 'Comman

  • Keynote 1.1.1 with Leopard 10.5.3

    Anyone have this working? I try to launch Keynote, it tries to load a theme, and bam! Keynote unexpectedly quit...blah blah. please quit and relaunch the application. On top of that, I have had more kernel panics in the last 2-3 weeks since updating

  • SUN and Microsoft NT 4.0 DHCP Server

    Hi all, I have some old type Wyse Thin Client Terminal (Thin client type WinTerm 2300SE) and I am doing a migration from old network to the new network. On the old network, we are using a Microsoft NT4 DHCP Server and on the new network, we are using

  • Editing Movie Expiration Date in SWF? (lost project files)

    Hello, big fan of Captivate and now use Captivate 3. We use this for our customer demonstrations and training tutorials. One of my presentations took about 12 hours to "film" - I saved this project with a Movie Expiration as it is a sales presentatio

  • How do I recover my files?  Mac Proctector is on my computer. Please help me!

    I am trying to get rid of it. I am so not computer savy. It is the reason I bought a Mac to begin with. I am going to call my credit card companies, but how do I get rid of the pop ups?