Add some values from array B into array A only if other values exist in both.

Hi everyone,
If I have reference array $Food that has 2 property names that I'm going to use to compare to another array.....
Pie                 WasAte
blueberry         no
pecan               no
raspberry           no
And I collect another array called $HeAte.Pie that has values ( pie names ) I want to compare to the above $Food.Pie
Plus I want to edit values of $Food.WasAte to "true" at the same row number or index of $Food where also $Food.Pie matches $HeAte.Pie  So In this way I'm adjusting my reference array to show which pies I ate after considering the
comparison array.
I'm stuck.  I was actually making progress but I realized I had almost 30 lines of code of something.  I must be doing this wrong. I realize this is an elementary question but if some pro could point me in the right direction ..... I'm trying
my best this year to learn powershell and spread its power.

Something like that?
Compare-Object -ReferenceObject $Food -DifferenceObject $HeAte -Property pie -ExcludeDifferent -IncudeEqual | select pie | foreach { $food[$food.pie.IndexOf($_.pie)].wasat = 1 }
Powershell include powershell cmdlet like Compare-Object, Select-Object, Sort-Object that can make code much more simpler by masking underlying complexity.
Bruce Jourdain de Coutance - Consultant MVP Exchange http://blog.brucejdc.fr

Similar Messages

  • How can i store values from my String into Array

    Hi guys
    i wants to store all the values from my string into an array,,,, after converting them into intergers,,,, how i can do this becs i have a peice of code which just give me a value of a character at time,,,,charat(2)...BUT i want to the values from String to store in an Array
    here is my peice of code which i m using for 1 char at time
    int[] ExampleArray2 = new int[24];
    String tempci = "Battle of Midway";
    for(int i=0;i>=tempci.length();i++)
    int ascii = tempci.charAt(i); //Get ascii value for the first character.

    public class d1
         public static final void main( String args[] )
              int[] ExampleArray2 = new int[24];
              String tempci = "Battle of Midway";
              for(int i=0;i<tempci.length();i++)
                   int ascii = tempci.charAt(i);
                   ExampleArray2=ascii;
              for(int i=0;i<ExampleArray2.length;i++)
                   System.out.println(ExampleArray2[i]);

  • How to get a value from one item into another

    How can i get value from one item into another item.
    Ex: I have a report, in there i have check boxes, and when i have checked some rows, and press submitt, a prosses computates it into a item on another page, and a branche redirects to page 3. Then i'm going to use the value in the item into a PL/SQL script in an report to show the submittet items.
    How can i do this?
    Computation script, pages and all that is fixed. But i dont know which PL/SQL statement to use to get th value from the item.

    Hi Fredr1k,
    Use the V() function from pl/sql.
    e.g. V('P3_MY_ITEM')
    will return the value of that page item.
    As long as the pl/sql is called from within the Apex environment.
    Regards
    Michael

  • Putting attribute value from java level into sessionScope variable?

    Hallo,
    is it possible to put an attribute value from java level into a sessionScope variable?
    For example when i'am in prepareSession is it possible to fill a sessionScope variable which i can use in a jspx-Site? And when how i must do it?
    Any help is appreciated.

    At the java level i make this
    private void setUserIdIntoUserDataHashtable() {
    Integer userid = getUserIdForLoggedInUser();
    Integer groupid = getGroupIdForLoggedInUser();
    Hashtable userdata = getDBTransaction().getSession().getUserData();
    if (userdata == null){
    userdata = new Hashtable();
    userdata.put(PBConstants.CURRENT_USER_ID, userid);
    userdata.put(PBConstants.CURRENT_GROUP_ID, groupid);
    And when i at the java level i can use the constants. But i don't have an interaction at this point. Thats why i don't now how to bring the values to a sessionScope variable i need later in a / some sites?

  • Retrieving  the score value from the captivate into flash

    Hi,
    We have used Captive 2 to built course & publishing it as
    a non e-learning output
    and loading the published swf file in custom built flash
    movie (wrapper).
    We have accessed some of the captivate variables to control
    the captivate swf.
    Does anyone know how to retrieve the score value from the
    captivate into flash ?
    Thanks
    Regards
    Chetan

    Hello,
    Use the Object Browser in .NET and search on "Summaryinfo" and you'll find the API to use.
    Thank you
    Don

  • How To Concatenate Column Values from Multiple Rows into a Single Column?

    How do I create a SQL query that will concatenate column values from multiple rows into a single column?
    Last First Code
    Lesand Danny 1
    Lesand Danny 2
    Lesand Danny 3
    Benedi Eric 7
    Benedi Eric 14
    Result should look like:
    Last First Codes
    Lesand Danny 1,2,3
    Benedi Eric 7,14
    Thanks,
    David Johnson

    Starting with Oracle 9i
    select last, first, substr(max(sys_connect_by_path(code,',')),2) codes
    from
    (select last, first, code, row_number() over(partition by last, first order by code) rn
    from a)
    connect by last = prior last and first = prior first and prior rn = rn -1
    start with rn = 1
    group by last, first
    LAST       FIRST      CODES                                                                                                                                                                                                  
    Lesand         Danny          1,2,3
    Benedi         Eric           7,14Regards
    Dmytro

  • COPA - Split of Value from condition type into different value fields

    Dear All,
    Customer is having several free schemes to customer the same is set up by SD and Cost of free goods is attached to One Z condition type, this flows along with Main product as characteristic. So we have Main product cost in VPRS and Scheme cost in Z Condition and there is possibility of more than one scheme cost flowing in one Z condition for single billing document. Whereas customer request is to see the each scheme cost separately in COPA. Since Value from SD will be flowing through only one condition type , it will be difficult to me to Split this in COPA. We have given a thought of having more than one condition type from SD ( one Z condition for one scheme) but this resolve our issue at hand. If we look at long term whenever customer introduces new Scheme new condition type need to be created and related COPA changes etc, Which doesn't seem to be working out.
    Request Experts help in this, thanks in advance for the help.

    Hi Santosh
    Having a Z cond type for each scheme is preferrable.... This would address the issue with Standard SAP itself...
    Reason being, if you dont do that, then you will have to maintain a mapping somewhere in a Z Table where by system would come to know of the ratio between the schemes... This will be more cumbersome to develop and maintain... Still you wanna do that, here is the logic....
    Maintain the schemes in a Z Table... Where each scheme will have a scheme ID - The ratio applicable to various schemes and also the relevant value fields of COPA to be updated for each scheme....
    Now, add a Custom Field to the Sales Order and while creating the SO this field needs to be updated with the scheme ID(Relevant Exit to make it mandatory MV45AFZZ / ZB).... If Scheme ID is populated, your Billing should read the Split from Z Table using Exit RV60AFZZ and Update COPA using Exit COPA0002
    br, Ajay M

  • I have purchased adobe pdf pack so i can delete some text from my converted files, this will only let me add text but not delete any, please help

    i have purchased adobe pdf pack so i can delete some text from my converted files, this will only let me add text but not delete any, please help

    I tyhink that you need ExportPDF, Adobe ExportPDF (read only). In any case, thius may help: Cancel your membership or subscription | Acrobat.com online services

  • Save the selected value from listbox with its respective tab control dropdown selcted values in another listbox

    Hi all,
    I am making a vi where I have to save the selected value from listbox with its respective tab control dropdown selcted values in another listbox.Whenever I select Item1 then the heading change and respective tab will open for that item.But Now I just want to save the selection and put it in another ListBox.SO that I can renmove or add according to my wish. Plz help me.
    Solved!
    Go to Solution.
    Attachments:
    my_vi.png ‏83 KB

    Hi, I successfully make the vi to insert itmes from listbox1 to listbox2.Whenever I select itmes 1 in listbox 1 it display same elected item in listbox2 , but it not appending the items in listbox2.Like If 1 is selected in listbox1 then 1 will display , next time after saving when I selct next item like 3 then in listbox 2, 1 is replaced by 3,it dont come in second row of listbox2.Hope I am able to explain.\
    Plz help me to resolve this.
    Attachments:
    listbox_update.vi ‏11 KB

  • Xsql:set-page-param from multirow select into array variable

    I'd like to set an XSQL page array variable to the result of a query that returns multiple rows.
    Can I do something like this:
    <xsql:set-page-param name="users[]">
    select username from all_users
    </xsql:set-page-param>
    The documentation only mentions usage like
    <xsql:set-page-param name="users[]" value="SCOTT SYS SYSTEM"/>

    The set page param is only designed to look at the first column of the first row of its query results.
    If you supplied a PL/SQL function that would return the list of users as a space-or-comma-separated string, then you could use:
    select your_function() as user_list from dual
    and then add the treat-list-as-array="yes" attribute to achieve this.

  • Help:How to get a java String value from a C char array?

    Hi,everyone,could you help me?
    the following is a C struct that i want to recieve a short message:
    struct MO_msg{
    unsigned long long msgID;          //Message ID
    char      dest_id[21]; //Destination Mobile Phone Number
    char      service_id[10];     //
    Now I want to put the "dest_id " value of this struct into a Java String variable.But I dont know how to implement it!
    The following is a block of source code that i implement this functions.But it cant get a String value ,and throw out a Exception:
    java.lang.NullPointerException
    at java.lang.StringBuffer.append(StringBuffer.java:389)
    JNIEXPORT jint JNICALL Java_md_EMAP_thread_RubeMOTSSX_getMO
    (JNIEnv * env, jobject obj, jint connId, jobject mo){
         struct MO_msg MO;
         tssx_cmpp_api_debug_flag = 1;
         int result = CMPP_Get_MO((int)connId,&MO);
         if (result == 0){
              jclass cls = (*env)->GetObjectClass(env,mo);
              jfieldID msgId = (*env)->GetFieldID(env,cls,"msgId","J");
              jfieldID dest_Id = (*env)->GetFieldID(env,cls,"dest_Id","Ljava/lang/String;");
              jfieldID serviceId = (*env)->GetFieldID(env,cls,"serviceId","Ljava/lang/String;");          
              (*env)->SetLongField(env,mo,msgId,MO.msgID);               
              (*env)->SetCharField(env,mo,dest_Id,*destId);
              (*env)->SetCharField(env,mo,serviceId,MO.service_id);
         return result;
    Please help me!Thanks!

    bschauwe:Thank you for your help!
    Yes,just as you say,using NewString Or NewStringUTF can import a C char array into a Java String variable! But now I have another question,when i use these two functions ,i found that it cant deal with Chinese character!
    do you have such experiences to deal with another language charset?if you have ,can you tell me how to deal with it.

  • Sample Applescript: scraping values from numbers files into a master file

    Hi, I have programming experience in c and other languages, but am new to applescript and so am learning a lot from this forum.
    My goal is to make a timesheet system for my Dad (for a bday present) where every time he helps a client, he fills out a newly created numbers file - and after a week or so, he can run a script that scrapes certain values from each numbers file and places it into a master numbers file. Then saving and closing the file.
    Vince, it sounds like you've written a script that does this feature of looping through all numbers files in a folder and putting select values from each numbers file into a master numbers file (after clearing the previous values of the master file).
    Specifically, I'm looking for a sample script that opens up a numbers file, clears its table, then fills this table by scraping one value from a particular cell in every numbers file in a folder.
    If anyone has a similar script they would be willing to post or email to me, for me to use as a foundation and to learn from, I would be very very very grateful. My email is forman.jq at gmail dot com.

    I guess that this script may be a good starting point.
    --[SCRIPT fromfolder_2spreadsheet1]
    The target spreadsheet must be open at front and must contain the sheet sheet_destination which much contain the table table_destination.
    Choose the folder supposed to store the source sopreadsheets.
    Yvan KOENIG (VALLAURIS, France)
    2010/08/18
    --=====
    (* Edit these height properties to fit your needs *)
    property destination : "destinationDoc.numbers"
    property sheet_destination : "destination"
    property table_destination : "insert here"
    property premierelignedestination : 2
    property colonne_destination : 2
    property ledossierhabituel : "Macintosh HD Maxtor:Users:yvan_koenig:Desktop:dossier habituel:"
    property ligne_source : 2
    property colonne_source : 2
    --=====
    on run
    my activateGUIscripting()
    Select the folder storing the spreadsheets from which we will extract values *)
    set dossier_source to choose folder with prompt "Choose folder storing the Numbers documents…" default location (ledossierhabituel as alias)
    Build a list of disk items available in the selected folder *)
    tell application "System Events"
    set les_elements to every disk item of folder (dossier_source as text) --whose (get type identifier) is in
    set les_tableurs to {}
    Extracts the list of the Numbers spreadsheets available in the selected folder *)
    repeat with refsurelement in les_elements
    if type identifier of refsurelement is in {"com.apple.iwork.numbers.numbers", "com.apple.iwork.numbers.sffnumbers"} then
    copy path of refsurelement to end of les_tableurs
    end if
    end repeat
    end tell -- System Events
    if les_tableurs is {} then
    No Numbers documents available so we stop the process. *)
    set rapport to "The folder “" & dossier_source & "” doesn’t contain Numbers documents !"
    else
    set rapport to {}
    end if
    Check that the target Numbers document is open at front
    and that it embed the defined sheet embedding the defined table. *)
    tell application "Numbers"
    activate
    set existants to name of documents
    if destination is not in existants then
    copy "The document " & destination & " is not open !" to end of rapport
    else
    tell document destination
    if sheet_destination is not in (name of sheets) then
    copy "the sheet " & sheet_destination & " is unavailable in the document " & destination & " !" to end of rapport
    else
    tell sheet sheet_destination
    if table_destination is not in (name of tables) then copy "The table " & table_destination & " is unavailable in the sheet " & sheet_destination & " of the document " & destination & " !" to end of rapport
    end tell -- sheetSource
    end if
    end tell --document destination
    end if
    If target document is not at front or if it doesn't match the defined requirements,
    we quit the process. *)
    if rapport is not {} then error my recolle(rapport, return)
    Clean the target table, minus row 1 supposed to be storing columns headers *)
    tell document destination to tell sheet sheet_destination to tell table table_destination
    set selection range to range ("A2 : " & name of last cell)
    end tell --document destination
    end tell -- Numbers
    my selectMenu("Numbers", 4, 9) (* Suppress *)
    set liste_valeurs to {}
    tell application "Numbers"
    repeat with un_tableur in les_tableurs
    Open the spreadsheets and extract from each of them the wanted value *)
    open un_tableur
    tell document 1 to tell sheet 1 to tell table 1
    set une_valeur to value of cell 2 of column 2
    end tell
    if une_valeur is 0.0 then
    copy "empty" to end of liste_valeurs
    else
    copy une_valeur as text to end of liste_valeurs
    end if
    close document 1
    end repeat
    Now, it's time to insert the values in the target table *)
    set ligne_destination to premierelignedestination
    tell document destination to tell sheet sheet_destination to tell table table_destination
    repeat with une_valeur in liste_valeurs
    if not (exists row ligne_destination) then add row below last row
    if une_valeur is not "empty" then
    set value of cell ligne_destination of column colonne_destination to une_valeur
    end if
    set ligne_destination to ligne_destination + 1
    end repeat
    end tell -- document destination
    save document destination
    end tell -- Numbers
    end run
    --=====
    on recolle(l, d)
    local oTIDs, t
    set oTIDs to AppleScript's text item delimiters
    set AppleScript's text item delimiters to d
    set t to l as text
    set AppleScript's text item delimiters to oTIDs
    return t
    end recolle
    --=====
    on activateGUIscripting()
    (* to be sure than GUI scripting will be active *)
    tell application "System Events"
    if not (UI elements enabled) then set (UI elements enabled) to true
    end tell
    end activateGUIscripting
    --=====
    my selectMenu("Pages",5, 12)
    ==== Uses GUIscripting ====
    on selectMenu(theApp, mt, mi)
    tell application theApp
    activate
    tell application "System Events" to tell process theApp to tell menu bar 1 to ¬
    tell menu bar item mt to tell menu 1 to click menu item mi
    end tell -- application theApp
    end selectMenu
    --=====
    --[/SCRIPT]
    I apologize, I'm too busy to write more explanations.
    Yvan KOENIG (VALLAURIS, France) mercredi 18 août 2010 21:38:04

  • How do I add old photos from my MacbookPro into my photo stream to view on my iPhone

    I'd like to add old photos saved onto my MacbookPro into my photo stream so that I can view them on my Iphone.
    I have tried selecting 'share' when looking at the photo in iPhoto - and then selecting to share it to my photo stream but i can't see it in the stream on either of the devices.
    Is there some sort of delay before uploading?
    Please help. Thank you

    mads111 wrote:
    That's what I was doing but they just don't seem to show up at all. Even when I drop and drag them from the iPhoto into the stream.
    Is there a limit on how many photos can be in the stream at one time?
    yes definitely. 1000.  THe oldest are deleted. THis may be your problem.

  • Inserting a value from page field into an xml file

    Hi there,
    I have added a field 'Comments' on a create vacancy page.
    There are other fields on that page and the values from those fields are getting stored in an xml file.
    This xml file is getting stored in TRANSACTION_DOCUMENT column of table HR_API_TRANSACTIONS.
    Is it possible to add the value from the field (that I've added on the page) into the same xml file?
    If yes, please tell me how
    and if no, tell me what should I do to store that value.
    Regards,
    Gaurav.

    Hi Gaurav,
    You need to check in seeded files for the logic of generation of XML file and setting it in DB column. May be in PLSQL API this code would exist.
    Once you get that logic you can append your column value in XML tag (need to create new tag) if you are allowed to modify seeded API. Otherwise use free additional attributes of the table.
    Hope I am clear.
    Regards,
    Mukesh Uchaniya

  • Returning a value from a query into an application item

    Hi,
    I have a insert statement defined in a process which I require that after inserting some data (from which the primary key is fetched from a sequence within a trigger on the table ra_assessments) that this key is then returned into the application item :GBL_CURRENT_ASSESSMENT. The code I have attempted to use is:
    begin
    insert into ra_assessments values(
    NULL,
    --rest of the fields here ) RETURNING id INTO :GBL_CURRENT_ASSESSMENT;
    end;
    Now, this works fine if I want to return into a page level item (say :P2_ID) however it does not appear to return correctly into an application item. The application item is unrestricted.
    Any help/suggestions would be very much appreciated.
    Thanks

    hi,
    There is nothing polpulating :P2_ID - I created the page item as a test instead of populating :GBL_CURRENT_ASSESSMENT. So, I then changed the code above to read:
    begin
    insert into ra_assessments values(
    NULL,
    --rest of the fields here ) RETURNING id INTO :P2_ID;
    end;
    which successfully populates :P2_ID with a value. It will not however populate :GBL_CURRENT_ASSESSMENT when I use that in the place of :P2_ID in the example above.
    I hope this makes sense! :)
    cheers,
    Message was edited by:
    /dev/null
    -Bad sppeling! :-Þ

  • Post values from selection screen into vkm5 transaction

    Hi all,
    i need to create a report , when user enters values in the selection screen of that report, that values must be transported into a transaction VKM5 and then that transported values must be updated in a ztable.
    ex:
    in selection screen if user enter doc no:xxxxxx
                                                         date:  20.09.2011
                                                         Reason for release: some text
    then that doc no: xxxxx must be transported into vkm5 transaction and that values(selection screen values) must be uploaded into a ztable.
    i tried the below code
    TABLES: ZVKM5.
    data: IT_ZVKM5 type standard table of ZVKM5,
          WA_ZVKM5 type ZVKM5.
    PARAMETERS    : S_VBELN LIKE ZVKM5-VBELN ,
                    s_date LIKE  zvkm5-bldat ,
                    s_text LIKE  zvkm5-text .
    call transaction 'VKM5'.
    *LOOP AT IT_ZVKM5 INTO WA_ZVKM5.
       WA_ZVKM5-VBELN = S_VBELN.
       WA_ZVKM5-bldat = S_DATE.
       WA_ZVKM5-text  = S_TEXT .
       modify ZVKM5 from table IT_ZVKM5.
      if sy-subrc = 0.
      endif.
    *ENDLOOP.
    Kindly suggest me,
    thanks in advance,
    ben2012.

    Thanks to all ,
    Solved by me.
    REPORT  ZVKM5.
    TABLES: ZVKM5, vbuk.
    types: begin of ty_zvkm5 ,
           vbeln type VBELN_VL,
           BLDAT type BLDAT,
           TEXT type TEXT,
           UNAME TYPE CDUSERNAME,
      end of ty_zvkm5.
    TYPES: BEGIN OF TY_CDHDR,
           OBJECTID TYPE CDOBJECTV,
    END OF TY_CDHDR.
    DATA: IT_CDHDR TYPE TABLE OF TY_CDHDR,
          WA_CDHDR TYPE TY_CDHDR.
    data: IT_ZVKM5 like ZVKM5 occurs 0 with header line,
          WA_ZVKM5 type ty_ZVKM5.
      DATA: bdcdata_wa  TYPE bdcdata,
            bdcdata_tab TYPE TABLE OF bdcdata.
    data: date type STRING.
    PARAMETERS    : S_VBELN LIKE ZVKM5-VBELN ,
                    s_date LIKE  zvkm5-bldat ,
                    s_text LIKE  zvkm5-text .
          CLEAR bdcdata_wa.
          bdcdata_wa-program  = 'RVKRED05'.
          bdcdata_wa-dynpro   = '1000'.
          bdcdata_wa-dynbegin = 'X'.
          APPEND bdcdata_wa TO bdcdata_tab.
          CLEAR bdcdata_wa.
          bdcdata_wa-fnam = 'BDC_CURSOR'.
          bdcdata_wa-fval = 'VBELN-LOW'. " pass the field name
          APPEND bdcdata_wa TO bdcdata_tab.
          CLEAR bdcdata_wa.
          bdcdata_wa-fnam = 'VBELN-LOW'. " pass the field name
          bdcdata_wa-fval =  S_VBELN. " pass the date here
          APPEND bdcdata_wa TO bdcdata_tab .
    call transaction 'VKM5' using bdcdata_tab .
    REFRESH IT_ZVKM5.
    SELECT  OBJECTID
            FROM CDHDR INTO TABLE IT_CDHDR.
    LOOP AT IT_CDHDR INTO WA_CDHDR.
    IF WA_CDHDR-OBJECTID  = S_VBELN.
    move s_vbeln to it_zvkm5-vbeln.
    move S_date to it_zvkm5-bldat.
    move s_text to it_zvkm5-text.
    MOVE SY-UNAME TO IT_ZVKM5-UNAME.
    append it_zvkm5 to it_zvkm5.
    modify zvkm5 from  table it_zvkm5.
    UPDATE zvkm5.
    ENDIF.
    ENDLOOP.
    CLEAR: S_VBELN, S_DATE, S_TEXT.

Maybe you are looking for

  • Problem in passing parameters in command line in desktop

    Hi, I am trying to generate reports from command line (Oracle Discoverer 4i Version 4.1.42.04.00) but I am facing problems when I try to pass date or numeric parameters. It seems to work with strings The following command is successful when i pass st

  • 648 Max no booting (all leds are RED)

    Hello, I use my 648 Max mother board for 2 year with : - P4 @ 2,4 Ghz - two PC2700 DDR 512 Mo - the D-Bracket 2 - two hard disk - a nvidia g-force 2 - a lan pci - sound blaster live! 5.1 Since yesterday, my computer don't start (whithout hardware cha

  • Bluetooth Gone Missing

    Some way or another, bluetooth has gone missing from my System Preferences pane. I restarted my computer a few days ago and noticed that it was gone. In the past I have used the OS X installation CD and Pacifist to fix problems like this but I'm not

  • FrameMaker 8 Track Changes - Customize?

    Oh, I was so excited when FrameMaker 8 came out with track changes feature. and oh, was I disappointed when I got a trial copy and found out that I cannot find a way to customize the way those changes are displayed. It appears that deletions and inse

  • How to flatten ID pdf?

    I've had trouble with my .pdf files not being flattened to one layer after exporting from ID CS4. I have to open them in PS and hit flatten image or I get shadows around some of the text. How can I flatten the layers before exporting?  Thanks!