Powershell - Help with returning dynamic variable values

Add-Type -AssemblyName System.Windows.Forms
$frm1 = New-Object System.Windows.Forms.form
$frm1.Name = "Hey"
$flw1 = New-Object System.Windows.Forms.FlowLayoutPanel
$flw1.flowdirection = 'TopDown'
$frm1.controls.add($flw1)
$m = "apple","orange","banana"
for($i=0;$i -le $m.Length-1;$i++){
$lb = New-Object System.Windows.Forms.linkLabel
$lb.text = $m[$i]
$m[$i] = $null
$flw1.Controls.Add($lb)
$lb.add_Click({Write-Host $lb.text})
$frm1.showdialog()
Could someone please help me with a method to return the value of the label that was clicked? Or a means to identify which linklabel was clicked. Thank you.

Hi, jrv-
Awfully sorry to trouble you. Could you please assist with the solution to this script or a better way to approach this scenario? I need to return the current value of label ($lb) from the form ($frm1), when $btnfrm2 on form ($frm2) is clicked.
Thank you.
Add-Type -AssemblyName System.Windows.Forms
$frm1 = New-Object System.Windows.Forms.form
$frm1.Name = "Hey"
$flw1 = New-Object System.Windows.Forms.FlowLayoutPanel
$flw1.flowdirection = 'TopDown'
$frm1.controls.add($flw1)
$m = "apple","orange","banana"
function frmDisplay{
$frm2 = New-Object System.Windows.Forms.Form
$btnfrm2 = New-Object System.Windows.Forms.Button
#$btnfrm2.Add_Click()
$btnfrm2.text = 'Click'
$frm2.Controls.Add($btnfrm2)
$frm2.Add_Shown({$frm2.Activate()})
[void] $frm2.ShowDialog()
for($i=0;$i -le $m.Length-1;$i++){
$lb = New-Object System.Windows.Forms.linkLabel
$lb.text = $m[$i]
$m[$i] = $null
$flw1.Controls.Add($lb)
$lb.add_Click({Write-Host $this.text; (frmDisplay)})
$frm1.showdialog()

Similar Messages

  • Need help with the session state value items.

    I need help with the session state value items.
    Trigger is created (on After delete, insert action) on table A.
    When insert in table B at least one row, then trigger update value to 'Y'
    in table A.
    When delete all rows from a table B,, then trigger update value to 'N'
    in table A.
    In detail report changes are visible, but the trigger replacement value is not set in session value.
    How can I implement this?

    You'll have to create a process which runs after your database update process that does a query and loads the result into your page item.
    For example
    SELECT YN_COLUMN
    FROM My_TABLE
    INTO My_Page_Item
    WHERE Key_value = My_Page_Item_Holding_Key_ValueThe DML process will only return key values after updating, such as an ID primary key updated by a sequence in a trigger.
    If the value is showing in a report, make sure the report refreshes on reload of the page.
    Edited by: Bob37 on Dec 6, 2011 10:36 AM

  • I need Help with the dynamic link feature in CS3

    Hi I was wondering if anyone could help me with an issue I am having? I have the adobe cs3 master collection. Having watched tutorials on the dynamic link feature my version seems not to have the same options as those I have viewed. I wish to send my premiere video creation to encore using dynamic link, however when I click "file" and then "adobe dynamic link" the only options available are about "adobe after effects". I can export to encore however I am only alloowed to export one premiere sequence to one new encore file, I cannot create an encore file and import several premiere sequence into the same encore project. That means currently I can only have an encore creation with one premiere sequence in it, and I have no adobe dynamic link. Any help anyone could offer would be greatly appreciated.

    Thanks very much for that guys but my premiere media encoder only lets me export as: MPEG1, MPEG1-VCD, MPEG2, MPEG2 blu-ray, MPEG2-DVD, MPEG2-SVCD, H.264, H.264 blu-ray, Adobe Flash Video, Quicktime, Real Media, Windows Media. Are any of these formats DV AVI?
    Am I to export my videos direct to encore or save them elsewhere (e.g desktop). It seems that I cannot export sequences from different premiere projects to the same encore project.
    Sorry if any of these questions seem obvious, I am just new to premiere and keen to do things right from the off.
    Many thanks again guys.
    Date: Tue, 24 Nov 2009 19:32:47 -0700
    From: [email protected]
    To: [email protected]
    Subject: I need Help with the dynamic link feature in CS3
    Harm is correct.  For SD DVD, exporting as a DV AVI file from Pr will give you good results.  Encore's Automatic Transcoding will give you maximum quality for the available disc space.
    -Jeff
    >

  • Help with updating PATH variable

    I am using a T42 with WinXp pro
    I installed JAVA SDK then I tried to update my cmd window path permanently so that I don't have to typed in the full path everytime, so I followed the description:
    Microsoft Windows NT, 2000, and XP - To set the PATH permanently:
    Choose Start, Settings, Control Panel, and double-click System. On Microsoft Windows NT, select the Environment tab; on Microsoft Windows 2000 select the Advanced tab and then Environment Variables. Look for "Path" in the User Variables and System Variables. If you're not sure where to add the path, add it to the right end of the "Path" in the User Variables. A typical value for PATH is:
    C:\j2sdk1.4.2_<version>\bin
    Capitalization doesn't matter. Click "Set", "OK" or "Apply".
    The PATH can be a series of directories separated by semi-colons (;). Microsoft Windows looks for programs in the PATH directories in order, from left to right. You should only have one bin directory for a Java SDK in the path at a time (those following the first are ignored), so if one is already present, you can update it to j2sdk1.4.2_<version>\bin.
    The new path takes effect in each new Command Prompt window you open after setting the PATH variable.
    The wired thing is that there is no variable named: PATH in my environmental variables, so I added a new one, and it did not work, the one that I always get when I do run-> cmd is
    c:\> documents and settings\my user name
    which I found out is the so called"HOMEPATH", and it is not seen in the environmental variables tab.
    How can I change it permanetly? Please help me

    then I run cmd again, I still get
    C:\Documents and Settings\user>set path
    Path=C:\JAVA\j2sdk1.4.0\bin
    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WS
    ;.pyo;.pyc;.py;.pyw
    It did not seem to help. The path variable that cmd
    uses remained the same.In Reply #2, you said the set path shows "Path=C:\WINDOWS\System32" Now you say "Path=C:\JAVA\j2sdk1.4.0\bin" That makes it look like changed the path. If you enter "javac" it should run. However, I recommend that you go back into the Environmental Variables and change the Path you added so it says "C:\JAVA\j2sdk1.4.0\bin;C:\WINDOWS\System32"

  • Open a crystal report from WAD with passing  the variables values

    Hi,
    I need to know is there any way to link SAP WAD to crystal reports (open a crystal report from WAD)and pass the values of the variables which are entered in the Web App. (e.g. Customer id,year) should be passed to the Crystal Report.
    Maybe we need to pass parameter by WAD URL but this is just my assumption and have no idea how to do this with passing variable values.
    right now I know the method of how Bex queries which are used as data source for crystal reports but in my current scenario we have the structure like this that bex queries link with WAD and then WAD is linked with crystal reports.
    No doubt that Crystal report is target option in RRI but there the source is Bex Query only but in current scenario we are looking  WAD (web template) as a source to crystal report or crystal report called in WAD.
    Please suggest something on same.
    Thanks
    Take care
    Vishal sharma

    Hello Vishal.
    Did you find a solution for this problem?
    I'm facing right now the same problem, I need a way to link SAP WAD to crystal reports (open a crystal report from WAD) and pass the values of the variables which are entered in the Web App. (e.g. Customer id,year) should be passed to the Crystal Report.
    Have found an answer to this issue? If yes, please kindly inform how have you solved this.
    Best Regars
    Armando Santos

  • Dynamic variable value based on a value from xml

    I have a invoice template and it is for 4 different companies in my organization. Based on the organization I need to have a different value for a variable that adds blank lines to the end of the invoice. Is there anyway to assign a value to variable based on the value of a xml tag.
    Thanks

    I should have explained better before. I have one invoice template and we want to keep it one template for all companies. Each invoice is run individually, each companies footer is different, I am calling multiple headers and footers based on each company. Since the headers and footers are different I need to be able to add different amounts of lines and the end of each invoice depending on that company. I have accounted for the page break in my logic based on the amount lines the page is long. I just need a dynamic variable that I can assign different values on the fly.
    Thanks

  • Naming the evaluated case statement field with concatenating input variable value

    Hi,
    I am trying to add the input variable value to case statement evaluated field like below query:
    declare @Year varchar(4)
    select ProductCode,datepart(mm,Date) MonthValue,
      case when datepart(mm,Date) = 1 then sum(Price) else 0 END AS Jan+@Year,
      case when datepart(mm,Date) = 2 then sum(Price) else 0 END AS Feb+@Year,
      case when datepart(mm,Date) = 3 then sum(Price) else 0 END AS Mar+@Year,
      case when datepart(mm,Date) = 4 then sum(Price) else 0 END AS Apr+@Year,
      case when datepart(mm,Date) = 5 then sum(Price) else 0 END AS May+@Year,
      case when datepart(mm,Date) = 6 then sum(Price) else 0 END AS Jun+@Year,
      case when datepart(mm,Date) = 7 then sum(Price) else 0 END AS Jul+@Year,
      case when datepart(mm,Date) = 8 then sum(Price) else 0 END AS Aug+@Year,
      case when datepart(mm,Date) = 9 then sum(Price) else 0 END AS Sep+@Year,
      case when datepart(mm,Date) = 10 then sum(Price) else 0 END AS Oct+@Year,
      case when datepart(mm,Date) = 11 then sum(Price) else 0 END AS Nov+@Year,
      case when datepart(mm,Date) = 12 then sum(Price) else 0 END AS Dec+@Year
    from Sales_Imports where datepart(yyyy,Date) = @Year
    group by  ProductCode, datepart(mm,Date)
    Please help me any other way as this is not working...
    Thanks,
    Srini

    create table Sales_Imports (ProductCode int, Price int, [date] date)
    insert into Sales_Imports values
    (1,10,'1/1/2014'),(1,109,'2/1/2014'),(1,10,'1/1/2014'),(1,109,'12/1/2014'),
    (2,10,'1/1/2014'),(2,109,'2/1/2014'),(2,10,'10/1/2014'),(2,109,'12/1/2014')
    declare @Year varchar(4)='2014'
    DECLARE @MaxCount INT, @SQL NVARCHAR(max) ,@i INT;
    Set @MaxCount = 12 
    SET @i = 0;
    SET @SQL = '';
    WHILE @i < @MaxCount
    BEGIN
        SET @i = @i + 1;
        SELECT @SQL = @Sql + ', SUM(CASE WHEN datepart(mm,[Date]) = ' + cast(@i AS NVARCHAR(10)) + ' THEN  Price Else 0 END) AS ' +Left(DateName(month,Dateadd(month,@i-1,0)) ,3)+@Year
    END
    SET @SQL = N' SELECT  ProductCode, datepart(mm,Date) MonthValue ' + @SQL 
    + N' FROM  Sales_Imports
     where datepart(yyyy,Date) ='+ @Year + N'group by  ProductCode, datepart(mm,Date)
     Order by ProductCode, datepart(mm,Date)';
    --PRINT @SQL;
    execute (@SQL);
    --Or your original one
    declare @Year varchar(4)
    Set @Year ='2014'
    declare @SQL  Nvarchar(4000)
    SET @SQL=
    N' select ProductCode,datepart(mm,Date) MonthValue,
      case when datepart(mm,Date) = 1 then sum(Price) else 0 END AS [jan' +@year+'],
      case when datepart(mm,Date) = 2 then sum(Price) else 0 END AS [feb' +@year+'],
      case when datepart(mm,Date) = 3 then sum(Price) else 0 END AS [Mar'+@year+'],
      case when datepart(mm,Date) = 4 then sum(Price) else 0 END AS [Apr'+@year+'],
      case when datepart(mm,Date) = 5 then sum(Price) else 0 END AS [May'+@year+'],
      case when datepart(mm,Date) = 6 then sum(Price) else 0 END AS [june'+@year+'],
      case when datepart(mm,Date) = 7 then sum(Price) else 0 END AS [july'+@year+'],
      case when datepart(mm,Date) = 8 then sum(Price) else 0 END AS [Aug'+@year+'],
      case when datepart(mm,Date) = 9 then sum(Price) else 0 END AS [Sep'+@year+'],
      case when datepart(mm,Date) = 10 then sum(Price) else 0 END AS [Oct'+@year+'],
      case when datepart(mm,Date) = 11 then sum(Price) else 0 END AS [Nov'+@year+'],
      case when datepart(mm,Date) = 12 then sum(Price) else 0 END AS [Dec'+@year+']
    from Sales_Imports where datepart(yyyy,Date) = ' + @Year +N' group by  ProductCode, datepart(mm,Date)'
    --print @Query
    Execute (@SQL)
    drop table Sales_Imports

  • I am a rookie and need help with max and min values

    Hello all, i am into this intro to java class. my assignment is to write a program that prompts the user for two integers and then prints the sum, difference, average, product , distance (absolute value of the difference) Maximum(largest of the two) and Minimum(smallest fo the two) here is my code so far
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.lang.Math;
    public class Sample4
       public static void main(String[] args) throws IOException
          try // attempt the following
    {           // create the stream to read from
    InputStreamReader istream = new InputStreamReader(System.in);   // create a buffer to hold the stream
    BufferedReader console = new BufferedReader(istream);           // prompt the user
          System.out.println("Enter a number please");              // get input as a string
          String input = console.readLine();                        // convert to an integer
          int num1 = Integer.parseInt(input);
          System.out.println("Enter a number please");              // get input as a string
          String input2 = console.readLine();                       // convert to an integer
          int num2 = Integer.parseInt(input2);
          int sum = num1 + num2;                                    // get the sum of the two inputs
          int difference = num1 - num2;                             // get the difference of the two inputs
          int product = num1 * num2;                                // get the product of the two inputs
          int average = sum / 2;                                    // get the average of the two inputs
          int abs = Math.abs(difference);                           // get the absolute value of the two inputs
              // new section
                 // display the number
          System.out.println("The total sum = " + sum);
          System.out.println("The total difference = " + difference);
           System.out.println("The total product = " + product);
           System.out.println("The total average = " + average);
           System.out.println("The total absolute value = " + abs);
    } // if something breaks, catch the exception
    catch (IOException e)
       System.out.println(e); // displays the exception
       System.exit(1);  // quits the program
    }what will be the right syntax or code to find the MAX and MIN values of two numbers a User Inputs, hope someone can help with this. thank you for your help.

    Thanks alot man, sheesh i do not know why my book
    doesnt give me all the static methods. but i do really
    appreciate your help. peaceA complete list of the java.lang.Math methods can be found at http://java.sun.com/j2se/1.4/docs/api/java/lang/Math.html
    btw,
    max(a, b) == (a > b) ? a : b
    min(a, b) == (a < b) ? a : b

  • Dynamic CSV file name in target (Multiple workflow calling same dataflow with new global variable value)

    Hi their,
    I have multiple data flows doing 90% of the process same. The difference is in source query where clause and target flat file.
    I used the global variables to dynamically change the query where clause easily, but I need help in dynamically changing the target flat file (CSV file).
    What I want to do is have multiple workflows, which will first set the global variable to new value in the script box and then call the same data flow.
    Please let me know if you have any solution or any idea which might put me in the direction to my quest for solution.
    thank you,

    Hi Raj - in your content conversion for lineitem .. read the additional attribute as well.
    Change your source strcture and additional field company_code
    As you are already sending the filename for each line item using the UDF.. it's just you need to modify your UDF to take another input i.e. Company Code.
    or
    If your PI version is > 7.1 use the graphical variable to hold the filename..
    and while sending the company code information for every item just use the concat function to append filename & company code..
    http://scn.sap.com/people/william.li/blog/2008/02/13/sap-pi-71-mapping-enhancements-series-using-graphical-variable

  • Help with php session variables

    I am using Dreamweaver 8 to set up a dynamic app with PHP and
    MySQL. I want the code that the user logs in with ('UPN') to be
    stored as a session variable so that recordsets on subsequent pages
    can be set to display personalised data.
    I have set the session variable like this: $_SESSION['UPN'] =
    'UPN' (UPN is the name of the form textfield, also set as the
    username for logging in)
    On the data page, I have called the variable like this:
    $query_Recordset1 = ("SELECT pupils.pupilID, pupils.UPN,
    pupils.forename, pupils.surname FROM pupils WHERE UPN = '" .
    $_SESSION['UPN'] . "'");
    The recordset returns nothing- the dynamic table returns ony
    the column headings (both as headings and immediately under where
    you would expect the data to be).
    Can anyone help?
    Thanks

    On Wed, 17 Oct 2007 11:43:04 +0000 (UTC), "denman"
    <[email protected]> wrote:
    > I have set the session variable like this:
    $_SESSION['UPN'] = 'UPN' (UPN is
    >the name of the form textfield, also set as the username
    for logging in)
    Your code assigns the literal string UPN to the session
    variable. If
    it's coming from POSTed form data, you'd need to do it like:
    $_SESSION['UPN'] = $_POST['UPN'];
    Gary

  • Help with returning query from loadURL()

    I finally came across loadURL() and figured out that I can
    use it to invoke my ColdFusion components without page
    reloading--very handy!
    Now, I need to figure out how to do this to return values
    from my components. Has anyone done this and have an example I
    could see, or at least point out to me a suggestion of code for
    successfully doing this?
    Right now, my component looks like this:
    <cfcomponent output="no">
    <cffunction name="getComments" access="remote"
    output="no" returntype="query">
    <cfset var rsComments = "">
    <cfquery name="rsComments" datasource="xmlTest">
    SELECT *
    FROM comments
    ORDER BY commenter DESC
    </cfquery>
    <cfreturn rsComments>
    </cffunction>
    </cfcomponent>
    I am trying to use loadURL() as follows:
    function myQuery() {
    var myDatasetURL = 'xmlTest.cfc?method=getComments';
    var req = Spry.Utils.loadURL("GET", myDatasetURL, true);
    In Firebug, the "Response" shows a serialized WDDX packet.
    I've not really messed with these before, so any help would be
    greatly appreciated!
    Thanks
    Joel

    Your first mistake was to choose an array. An array has a fixed length, so it's not appropriate for storing a sequence whose length you don't know in advance. You should choose a List instead; an ArrayList would be a reasonable implementation to choose.
    Then you just add the Point to the ArrayList. Here's how you declare it:
    List<Point> points = new ArrayList<Point>();and here's how you use it in the listener:
    points.add(evt.getPoint());Returning anything from the listener to its caller, which is something buried in the GUI hierarchy, would be... um... pointless.

  • Help with setting an IF value when using a Pop-up Value

    Hello,
    I'm hopeful that someone out there has enough understanding with numbers to help me figure out how to program this function.
    I'm trying to create a spreadsheet that will allow me to track payments that have been reimbursed for a given service provided in a medical clinic. As the payout from the insurance companies is not only variable with time before reimbursement, but also with the actual amount that the each reimburses for a given procedure - I'm trying to create a system to track this all.
    So,  here's what I've got so far:
    On one sheet, I've created a one column - in which I've created a pop-up menu selection using three of the insurance companies that we bill out to regularly (let's call it Column I - cell I2).  On "another" sheet, I've created a list of values comprised of what the actual reimbursement from each of the three companies is for the particular service provided, in dollar amounts.
    What I'm trying to do, is set it up so that when I select say "First Choice" from the pop-up menu (cell "I2), the dollar value from the "other" sheet appears in the column following that of the pop-up menu column (column I),  with this new value now in (Column J) - cell J2.  I had then planned on being able to create a row at the bottom of the entire sheet that could then "SUM" the values represented by the newly created J2 cell.
    Any help would be GREATLY appreciated!

    Hello
    I guess that the contents of the table "rates" is clear.
    In table "Main", standard cells of column E contain a popup menu with four items :
    "company 1"
    "company 2"
    "company 3"
    In standard cells of column I, the formula is :
    =IFERROR(VLOOKUP(E,rates :: $A:$B,2,0),"")
    Yvan KOENIG (VALLAURIS, France) jeudi 28 avril 2011 18:50:26
    Please :
    Search for questions similar to your own before submitting them to the community

  • Help with building dynamic website using tutorial (was: I know this is a repost but I'm still stuck!)

    Perhaps this was missed by the group but here goes:
    I am slogging thru a dynamic PHP tutorial but  I cant continue without losing some understanding of the process due to ?
    I am trying to complete the following:
    Building your first dynamic website – Part 2: Developing the back end
    However,
    my Insert record form dialog (below) looks like this, and I need to change both 'title' and 'blog_entry' values (as shown above), but I cannot make that choice in my form.
    I am using DW CC with the Deprecated Server Behavior from DMX zone.
    I have made sure my results match the tutorial, but I cant get past the above inconsistency in functionality.
    Any help would be appreciated.
    Thanks folks!

    The Columns area indicates which form field is used to insert a value in each column. Although the post_id and updated columns are listed as getting no value, their values are generated automatically by the database.
    Check that the title and blog_entry columns are being assigned the correct values. If either is marked as getting no value, it means that you have spelled the names of the form fields differently from the column names. Correct this by selecting the column name in the Columns area and selecting the form field's name from the Value pop-up menu.
    Nancy O.

  • Help with Before Image - Postive Values?

    Hi, I'm struggling with some values being incorrect in my ODS.  I have a current order with 1 order qty and 1 confirmed qty.  The order was created back in the beginning of the year and just recently got confirmed.
    In BW ODS it shows 1 order qty and 0 confirmed qty.  Which is incorrect.
    From everything I have read about ABR the Before Image Values in the change log should all be negative.  This is the sales item LIS extractor 2LIS_11_VAITM.
    When I look at the Before Image Record I see the order qty as negative 1(fine), but the confirmed qty is positive 1?  ( I would have thought the confirmed value should be zero in the before image).  How can the
    Before image record have a positive value?
    When I look at the After Image Records I see the order qty as pos 1 (fine) and confirmed qty is 0( I thought this should be 1).
    Can anyone help me out with this scenario?
    1. Why would the Before Image have a positive 1 for a confirmed qty?
    2. Why would the After Image have a 0 confirmed qty if the confirmation generated these records?
    Change Log Records
                       Order Qty     Confirmed Qty
    Before Image       -1                1
    After Image         1                0
    Thanks!

    Hi,
    Confirmed quantity can be negative in case of return I think.
    Before images are the opposite sign not necessarily negative values.
    So this does make sense.

  • Need help with Return syntax

    I though that the two pieces of code below would perform the same function but apparently i am missing something. The code is supposed to multiply two integers. Both use the add method.
    //Method that adds two integers this method works great
    public static int add(int a, int b)
             if(a <= 0)
                return (a < 0) ? add(MCH.succ(a), MCH.pred(b)) : b;
             else
                return (a > 0) ? add(MCH.pred(a), MCH.succ(b)) : b;
          }//The variable total is defined earlier as what ever a originally was and is not modified.
      //This method for multiplying also works great for positive numbers but i wanted to shorten it.
      public static int multiply(int a, int b)
              if(b==1)
                    return a;
              return multiply(add(total,a),--b) ;
        //This code i though was the same as above just in one line but apparently not
        //10*10 will return 10
        // 5*5 will return 5
        public static int multiply(int a, int b)
              return (b==1) ? multiply(add(total,a),--b) : a;
          }Why are the two sections of code returning different values. Any help is much appreciated

    I tried 5*6 which produced 5 as an answer using the second version of multiply so it looks like no matter what i put in the output is always the first int.

Maybe you are looking for