Using variables for function arguments AS2

  Hello,
I am trying to create a function in AS2.
After creating the function, I want to use values stored in variables for the function arguments rather than manually typing static values for carrying out the function calculation. Also, I want to use the function to assign a new value to the existing variable.
I have asked a similar question 2 days ago here and got the answer (thank you), but now I got one more question - How can I create the function to assign a value to the variable while that variable itself is also a function argument?
For example, I have 6 numeric variables:
var CoinA:Number = 10;
var CoinB:Number = 20;
var CoinC:Number;
var CoinD:Number = 30;
var CoinE:Number = 40;
var CoinF:Number;
Then I tried to create a function to assign values to variables CoinC and CoinF:
function CalculationA(FirstCoin, SecondCoin, ThirdCoin):Void {
     FirstCoin = SecondCoin + ThirdCoin;
CalculationA(CoinC, CoinA, CoinB);
CalculationA(CoinF, CoinE, CoinF);
The above code didn't really assign the values 30 and 70 to the variables CoinC and CoinF but instead, values of CoinC and CoinF are undefined.
Please give me the correct code if there's a correct way of doing this.
Thank you,

Here is one way of doing it, by passing a string value of the variable name instead of the actual variable name....
var CoinA:Number = 10;
var CoinB:Number = 20;
var CoinC:Number;
var CoinD:Number = 30;
var CoinE:Number = 40;
var CoinF:Number;
function CalculationA(FirstCoin, SecondCoin, ThirdCoin):Void {
     this[FirstCoin] = SecondCoin + ThirdCoin;
CalculationA("CoinC", CoinA, CoinB);
CalculationA("CoinF", CoinD, CoinE);
(Note that in your second function call I changed the coins since CoinF (ThirdCoin) is undefined at that point.)

Similar Messages

  • Using variables for answers to fill-in-the-blank questions

    Hello,
    For fill-in-the-blank questions, one has to provide answers. I want to provide these in the form of (user-created) variables, rather than in the form of fixed strings of characters (so then, as $$var1$$ rather than as 'rabbit'). I haven't been able to get this to work. The enter variable function is indeed available (in the properties panel), but it doesn't actually work (i.e. even if you select a variable to be entered, it doesn't actually get entered).
    Is there a way around the problem?
    1. NB that this same issue holds for text entry boxes (rather than fill-in-the-blank questions). If I could get this to work for text entry boxes, I would use them rather than fill-in-the-blank questions.
    2. One can use variables for answers to multiple choice questions. So I'm hoping I can get it to work for fill-in-the-blank questions as well.
    Thank you in advance. Marvin DuBois

    That would have been my suggestion. I don't have a dedicated blog post, but use TEB's for that kind of questions myself as well. And contrary to the widget/interaction I mentioned before, a TEB is an interactive object, which means it can be validated and there can be a score attached to it. But, it will not help you, since you have to add the correct answers in the same way as for a dropdown list in the FIB question (they are sort of TEB's there). And it is that list that doesn't allow to enter a variable instead of a fixed sequence of characters.
    Which means that you are back to the advanced actions, same as in my blog posts with the widget/interaction.
    Have a workaround (after all I am the workaround Queen) to have reporting, if you need to check only one TEB, described here:
    http://blog.lilybiri.com/report-custom-questions-part-2
    The idea is to use another interactive object that can have a score. In reality I use two instances of that same object: one with score 0 and one with score X and show the right one depending on the conditional action.
    However if you want to have multiple TEB's on the same slide, that have to be checked all with the same advanced action, than you'll need either the Mastery widget by InfoSemantics (only for SWF output) or Javascript.
    Lilybiri

  • What are Parameters? How are they differenet from Variables? Why can't we use variables for passing data from one sequnece to another? What is the advantage of using Parameters instead of Variables?

    Hi All,
    I am new to TestStand. Still in the process of learning it.
    What are Parameters? How are they differenet from Variables? Why can't we use variables for passing data from one sequnece to another? What is the advantage of using Parameters instead of Variables?
    Thanks in advance,
    LaVIEWan
    Solved!
    Go to Solution.

    Hi,
    Using the Parameters is the correct method to pass data into and out of a sub sequence. You assign your data to be passed into or out of a Sequence when you are in the Edit Sequence Call dialog and in the Sequence Parameter list.
    Regards
    Ray Farmer

  • Help with using variable for name of table in PLSQL block...

    I am trying to use a variable for the name of a table but getting errors ...i am sure I am close to the correct form here but something is wrong. I sure would appreciate some help!
    DECLARE
    ln_month Number;
    ln_day Number;
    ln_year Number;
    ls_year VarChar2(4);
    ls_prev_table VarChar2(30);
    ls_cur_table VarChar2(30);
    ln_prev_year Number;
    ls_prev_year VarChar2(4);
    ln_prev_month Number;
    BEGIN
    Select To_Number(To_Char(sysdate, 'MM')) into ln_month from dual;
    Select To_Number(To_Char(sysdate, 'DD')) into ln_day from dual;
    Select To_Number(To_Char(sysdate, 'YYYY')) into ln_year from dual;
    If ln_month = 01 Then
    ls_cur_table := "T_CPRS_FDW_CUR_JAN_ACTUALS";
    ls_prev_table := "T_CPRS_FDW_PREV_DEC_ACTUALS";
    ln_prev_year := ln_year - 1;
    /***above is where I am trying to use variables for assignement to years and months tables***//// ln_prev_month := 12;
    End If;
    /*------MORE IF STATEMENTS FOR EACH MONTH ---OF --THE YEAR ...AND its the following 2 variable statements that the compiler doesnt like! */
    If ln_day < 20 Then
    Delete from :ls_prev_table;
    INSERT INTO :ls_prev_table /*(STUFF TO BE INSERTED GOES HERE)*/
    HELP PLEASE!
    null

    Hi,
    The parser does not under variables directly in dml statements.u need to form a statement and the parse and execute the same...
    so the soln is
    Declare
    lv_stmt varchar2(250);
    Begin
    lv_stmt := 'Delete from '&#0124; &#0124;ls_prev_table;
    execute immediate lv_stmt;
    -- Same is the case with the insert stmt--
    End;
    This should solve ur problem.
    u could also give a direct call like
    execute immediate 'Delete from '&#0124; &#0124;ls_prev_table ;
    Note: This statement "execute immediate" holds good for oracle versions 8.x and above which makes the stmt very simple. For lower version u need to use the dbms_sql package to parse and execute the statement which has a series of statements for the same.
    Kiran

  • Using variable in function for FLASH video

    I have a webpage that uses PHP to pull a variable from a
    MySQL database.
    I would like to use that variable to tell my flash component
    what flash video to play. I cant seem to figure out how to place
    the variable in the function call to make it work.
    Also...The main page is in the root directory of my site with
    all my flash videos in a subfolder. I can't seem to get the videos
    to play on my main page unless they are in the same directory. I
    even tried to simply 'include' the movie into my existing page and
    it doesn't work.
    Any idea on either of these issues?
    (Is this even the correct forum area for this? I am new to
    using FLASH for this stuff)

    Thanks for the advice!
    Turns out I believe my answer lies in PHP, but I will check
    out the LoadVars help in FLASH too!
    Andrew

  • Having trouble with using variables in functions and after functions..

    Morning,
    I have simplified this, as it represents the core of what’s I obviously don't know how to do. 
    Problem:
    Say I populate that variable by reading in a list if IP addresses from file, finding the line that matches the hostname and place that string into the $IPAddress variable for use later throughout the script.   I did not run into a significant problem
    until I decided to convert the routine of looking up the IP address and populating the variable into a function.   As soon as I made it a function, and called that function, the $IPAddress variable only had the data in it until the function completed. 
    Once the function had done its work, and had placed the data into the variable, I expected that “new” data to be available after the function had completed..in that variable.  But it’s like the $IPAddress variable in the main script is a totally
    different data then the variable with the same name that’s used within the function. 
    So I think this demonstrates some of what’s kicking my butt.. 
    $IPAddress = "This is the wrong data”
    Function TestFunction () 
    $IPAddress  #call to display the contents of the variable at the start of the function. 
    $IPAddress = Read-Host -Prompt "Please enter the text ‘Goober’" 
    $IPAddress   #call to display the contents of the variable at the end of the function. 
    TestFunction
    $IPAddress ​
    The output I get is: 
    This is the wrong data
    "Please enter ‘Goober’"  : where I enter Goober
    Goober
    This is the wrong data
    Huh? 
    I had expected:
    This is the wrong data
    "Please enter ‘Goober’"  : where I enter Goober
    Goober
    Goober
    What good is the repeatability of a function if it’s output is lost? 

    THis seems to work.. IS there any reason NOT to do this?
    $Global:IPAddress= "This is the wrong data” #"
    Function TestFunction{
        Write-Host $IPAddress-fore green
          $host.ui.RawUI.FlushInputBuffer()
         $Global:IPAddress =
    Read-Host -Prompt
    "Please enter the text ‘Goober’"
        return$Global:IPAddress
    TestFunction
    return$Global:IPAddress

  • Global variable for function in JSP?

    Hi,
    In my JSP file I have a variable (sName) which I would like to use in a function. Is that possible? Do I have to declare it differently?
    Many thanks
    Simone
    Here the code fragement:
    <jsp:useBean id="s" class="ServiceRegistryClient"></jsp:useBean>
    <% Vector sName = s.getServiceNames(); %>
    <input type="Submit" name="callService" value="Call Service" onclick="callService()">
    <script language="javascript">
    function callService() {
    alert("Text" + sName.elementAt(0));
    }</script>

    Here's a sample jsp showing what I mean. It just posts back to itself:
    <HTML>
    <HEAD>
    <TITLE>Crappy JSP</TITLE>
    <%
    String element = null;
    java.util.StringTokenizer temp = null;
    String row = null;
    // get enumeration of parameters
    java.util.Enumeration names = request.getParameterNames();
    while (names.hasMoreElements()) {
      element = String.valueOf(names.nextElement());
      // get button name / row
      temp = new java.util.StringTokenizer(element, "_");
      if (temp.countTokens() == 2) {
        element = temp.nextToken(); // name
        row = temp.nextToken();  // row
      } else continue;
      // my button?
      if (element.trim().equals("callService")) {
           out.print("ROW NUMBER == " + row);
           break;
    java.util.Vector sName = new java.util.Vector();
    java.util.Vector sDescription = new java.util.Vector();
    java.util.Vector sLocation = new java.util.Vector();
    final int count = 3;
    for(int x = 0; x < count; x++) {
      sName.add("Name " + x);
      sDescription.add("Description " + x);
      sLocation.add("Location " + x);
    %>
    </HEAD>
    <BODY>
    <FORM action="../timesheet/Sample.jsp">
    <TABLE>
    <% for (int i = 0; i < count; i++) { %>
    <TR>
    <TD>
    <%= sName.elementAt(i) %>
    </TD>
    <TD>
    <%= sDescription.elementAt(i) %>
    </TD>
    <TD>
    <%= sLocation.elementAt(i) %>
    </TD>
    <TD>
    <input type="submit" name="callService<%= "_" + i %>" value="Call Service">
    </TD>
    </TR>
    <% } %>
    </TABLE>
    </FORM>
    </BODY>
    </HTML>

  • How can I use variable for a package filename and target file inODIFileMove

    I want to use a variable for paths so that when I migrate from Dev to QA to Prod I don't have to do a lot of editing.
    Specifically, I want a variable to be the first part of the path for the filename (\\sundev1\fnd1-hypd1) and join this with the rest (\update\log\*.log or specific filename) using several different objects like the ODIFileMove, ODI OS Command, OS Command, etc.
    Thank you!

    Hi,
    you could set up a database table holding processing parameters (i.e. Column1 - ParamName, Column2 - ParamValue).
    One row could then be ParamName = FilePath, ParamValue = \\<server>\folder\
    So, the refreshing query (attached to a logical schema) would be something like SELECT ParamValue FROM <your table> WHERE ParamName ='FilePath'
    Then, create a variable which can refresh from the database and in the package, drop the variable onto the flow and set it's type to 'Refresh Variable' in the properties.
    Hope this helps.
    geeo

  • Using type for function in sql

    CREATE OR REPLACE
    type InListType_number as table
    of number
    CREATE OR REPLACE function in_list( p_patseq in number ) return InListType_number
    as
    l_number number default p_patseq ;
    l_data InListType_number := InListType_number();
    begin
    loop
    exit when l_number is null;
    end loop;
    return l_data;
    end;
    SELECT p.pat_seq, p.diagnosis_type, ct.code_value || ' ' || p.alt_description as diagnosis_desc
    FROM patient_diagnosis p,
         (select * from code_set , code_set_type
         where code_set.code_set_type_seq =code_set_type.code_set_type_seq) ct
    WHERE p.enterprise_seq = (select enterprise_seq from org_lookup where organization_seq = 0 and rownum = 1)
    and p.diagnosis_code_seq = ct.code_set_seq(+)
    and (p.diagnosis_type LIKE 'A%' OR p.diagnosis_type LIKE 'W%')
    and p.PAT_SEQ IN (select /*+ CARDINALITY (t ) */* from table( cast( in_list (list of pat_seq here like 12345,12344,345666,etc over 1000 counts of pat_seqs)
    as InListType_number ) ) t)
    this gives me
    ORA-00939: too many arguments for function
    can someone advise? thanks

    Well IN_LIST takes a single parameter of type NUMBER and you are passing in
    12345,12344,345666which is patently multiple numbers. I think what you want to do is pass in a string ' 12345,12344,345666' and have a function TO_LIST() that parses the string and spits out numbers. Fortunately for you John Spencer has posted Re: Splitting the values in one column.
    Cheers, APC

  • Lexical Parsing exception using JXQI for function in XQuery

    How to parse Xquery containing new declared namespace, functions and then use the same function to operate upon Xquery along with it.....
    When i try to execute that XQuery using JXQI library, i get lexical parsing exception.......
    i m quite new to XQuery and that too its implementation in java, so i would b grateful for the help in advance !!

    Hi,
    Could you post the XQuery, and a sample XML document (if necessary)?
    Thanks.

  • Using variables for column headings in REUSE_ALV_GRID_DISPLAY

    Hi Everyone,
               Is it possible for me to display the column heading in REUSE_ALV_GRID_DISPLAY using a variable?
      CLEAR ls_fieldcat.
      ls_fieldcat-col_pos         =   13.
      ls_fieldcat-reptext_ddic      =  LWOP1.  " <===Here is my variable for my
                                                                          column heading
      ls_fieldcat-tabname           =  'ITAB'.
      ls_fieldcat-fieldname         =  'LWOP2'.
      ls_fieldcat-datatype          =  'CURR'.
      ls_fieldcat-outputlen       =  15.
      APPEND ls_fieldcat TO rt_fieldcat.
    Please help me.  Thanks in advance.

    for me isfielldcat-seltext_l = v_heading. working properly .
    i think you cant give
    ls_fieldcat-reptext_ddic = LWOP1.
    but i m not sure.
    regards
    shiba dutta

  • SPSiteDataQuery - filter by file Title - Can I use variable for the filter value?

    I use SPsiteDataQuery to search across multiple lists and filter by file title. I have the file title information in a variable.
    Can I use variable in the filter value?
    string fileName = "Policies.doc"
    SPSiteDataQuery spQry = new SPSiteDataQuery();
    spQry.ViewFields = "<FieldRef Name='Title'/><Value Type='Text'>fileName</Value>"

    If I have understood correctly, you want to search based upon a File title in all the sites. You can include a query to filename in the spQry
    spQry.Query = "<Where>" +
    "<Eq>" +
    "<FieldRef Name=\"FileLeafRef\"/>" +
    "<Value Type=\"Text\">" + fileName + "</Value>" +
    "</Eq>" +
    "</Where>";
    get2pallav
    Please click "Propose As Answer" if this post solves your problem or "Vote As Helpful" if this post has been useful to you.

  • Use variable for symbol name

    I am trying to reference a symbol element that looks like this:
    elementName = variableName + "Menu";
    var menuChoice = sym.getSymbol('printMenu').$(elementName);
    when I console.log ("menuChoice" + menuChoice) I get
    object Object
    How do I accomplish using a variable as a symbol name?

    Yes. I have a function that does a number of things so I am not looking to rewrite the menu Symbol.

  • How do i use variables for javascript pop up window?

    hi,
    i want to open a popup window from flash,
    as advised before i used this line :
    getURL("javascript:NewWindow=window.open('imylink.html','title','width=890,height=660,left =10,top=5,toolbar=No,location=No,scrollbars=Yes,status=No,resizable=Yes,fullscreen=No');
    void(0);");
    BUT, in flash, the URL that has to be open as do the height
    and wdth are stored as variable... imageURL, imageWidth,
    imageHeight, since i have quite a few different pages that have to
    open and they change. how can i use the values of the variables in
    the javascript code??
    is it possible at all?

    try:

  • XI 3.0 File receive comm.channel using variable for folder/file name schema

    Hi,
    I prepared a integration message to produce .txt file output of message.
    I prepared message successfully, it's running properly and producing .txt file.
    My problem is to set .txt file name.
    I must set file name using by some information in .txt file.
    I must get some part of the first line of .txt to set filename.
    I declared a variable to do it.
    How can i set referance of variable?
    payload:..?
    Thanks.

    Hi,
    this blogs might be helpful:
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=%28J2EE3417800%29ID0935780750DB11281184595516315205End?blog=/pub/wlg/13704
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=%28J2EE3417800%29ID0935780750DB11281184595516315205End?blog=/pub/wlg/2664
    http://www.sdn.sap.com/irj/scn/weblogs;jsessionid=%28J2EE3417800%29ID0935780750DB11281184595516315205End?blog=/pub/wlg/1888
    http://wiki.sdn.sap.com/wiki/display/XI/CombiningthreedifferentaspectsofPIinoneshot
    Regards
    Patrick

Maybe you are looking for

  • 100% advance payment during sales order creation

    Dear Experts,            One of our international client is having one requirement for collecting the 100% advance payment from customer during sales order creation itself. Our customer is in Germany. For high risk customers they want to collect the

  • Can we have properties value of keyfieldvalue more than one value?

    Hi all, Regards File content conversion that we can have properties value of keyfieldvalue more than one value? like a... row.keyFieldValue = 'aa','bb' I try define the value like this but I'm getting the error. Thanks and Regards Park

  • Why does the directory ~/var/log keep appearing?

    It doesn't matter how many times I delete it, every few hours the blank directory ~/var/log gets created on my computer. I think it may have something to do with my Brother HL2170W printer, which is connected to my wifi network. But that's just from

  • Printing to PS from Quark, InDesign, etc

    Hi, Got a PowerMac G5 running OS 10.4.11 in a commercial printing prepess environment,and up until recently I could print directly to a postscript file from any of the programs I use regularly with a preset that I had saved quite a while ago. I had t

  • 10.4.11 imac freezing during shutdown

    Hi, discovered my mother has been turning her imac off at the wall every night because when she tries to shutdown it freezes. It freezes at the point when the circular lines are spinning. Any suggestions?