Passing array values to an Applet from JSP

Hi,
I have a JSP page in which I've arrays that are populated from a DB. I want to pass these array values from the JSP page to a Applet in the same page. Is it possible ?
Any help will be appreciated.
:-) Praveen

Then the answer is no. The Applet doesn't exist until it is instanciated by the browser so the JSP running on the server can not pass Java Objects. You can either set up a javascript array, set the parameter tags in the HTML Applet tag or have the Applet open a URLConnection back to the server.

Similar Messages

  • Pass a value to the procedure from jsp

    Hi I need a help..
    I have a jsp page which has the value , And I have one stored procedure in a java file. I have to pass this
    selected month to that stored procedure. there are 2 input parameters and one out parameter which returns a date files. If i hard code the input parameters i am able to get the date field. the first parameter is in session, that is divisionCode. So no problem with that... but other value the selectedMoth "12/2003" should be passed from the jsp.
    help me how to achive this....
    my jsp code is
    <%
    String selectedMonth = request.getParameter("selectedMonth");
    String monthLastDate = callPLSQLFunc.getmonthLastDate(divisionCode);
    System.out.println("Month Last date is " +monthLastDate);
    %>my calling procedure
    public String monthLastDate(String divisionCode, String selectedMonth) {
            CallableStatement stmt = null;
            ResultSet rs=null;
            String lastDate ="";
          try {
              System.out.println("calling the procedure for month end date");
           //  stmt = con.prepareCall ("{?= call easmsa_front_end_routines_pkg.get_month_end_date(?,?)}");
             System.out.println("calling the procedure for month end date");
            stmt = con.prepareCall("begin easmsa_front_end_routines_pkg.get_month_end_date_prc(?,?,?); end;");
            stmt.setString(1,divisionCode);
            System.out.println("division Code is " +divisionCode);
            System.out.println("The last_date 1 ");
           //  stmt.registerOutParameter(2, oracle.jdbc.OracleTypes.VARCHAR);
             stmt.setString(2,selectedMonth);
             System.out.println("The last_date 2 " +selectedMonth);
             stmt.registerOutParameter(3, oracle.jdbc.OracleTypes.DATE);
             System.out.println("The last_date 3 ");
             stmt.execute();
             System.out.println("getting the value");
         //    lastDate = stmt.getDate(3);
             System.out.println(stmt.getDate(3));
        //     System.out.println("The last_date " +lastDate);
            } catch (SQLException e) {
                e.printStackTrace();
            return lastDate;
        public String getmonthLastDate(String divisionCode,String selectedMonth){
            String monthLastDate = monthLastDate(divisionCode,selectedMonth);
            return monthLastDate;

    Well, you'd just pass the parameter ....
    String monthLastDate = callPLSQLFun.getmonthLstDate(divisionCode, selectedMonth);
    [/code[
    ... or am I totall misunderstanding your question??
    Also, you have two methods which are public, and all one does is call the other with exactly the same parameters passed.  Why not just call monthLastDate() instead of getmonthLastDate() ... it does exactly th same thing, only without the extra call.
    I think maybe you need to grasp the basics of Java a little better before delving into the world of JSP.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Passing a value to an Applet from another server directory

    this is my problem:
    1) on our server we are logging a unique session_id: e.g: abc12345
    2) i want to pass the session_id value to the the applet.html file which calls applet.class
    Question:
    1) Can the applet.html file be in a different direcory from the applet.class file_?
    OR
    2) Would i have to use Javascript to pass the session_id value to applet.html_?
    ananda

    thanks smg123 - thats very helpful. I've tried experimenting with fixed URL's etc - and i keep getting security exceptions.
    In the following simple Applet.html code - could you give us a clue on how we would call Applet.class with Applet.html in a seperate directory - of course, keeping in mind that the Applet.class file is within Applet.jar_?
    ananda
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
    <html>
    <head>
    <title>test</title>
    </head>
    <body>
    <h1>test</h1>
    <applet
    codebase="com.esdu.glenrowan.viewpacs.J9611A10.userinterface.J9611A10Applet.class"
    code="J9611A10Applet.class"
    archive="J9611A10.jar"
    width=695 height=525>
    </applet>
    </body>
    </html>

  • I am trying to pass the value of a field from the seeded page /oracle/apps/

    I am trying to pass the value of a field from the seeded page /oracle/apps/asn/opportunity/webui/OpptyDetPG. The value I want is in the VO oracle.apps.asn.opportunity.server.OpportunityDetailsVO and the field PartyName.
    I have created a button on the page whose destination URL is
    OA.jsp?OAFunc=XX_CS_SR_QUERY&CustName={#PartyName}
    It opens the correct page, but in the URL it shows this
    http://aa.com:8005/OA_HTML/OA.jsp?OAFunc=XX_CS_SR_QUERY&CustName=&_ti=1897289736&oapc=177&oas=x5E2TIfP1Y0FykBt1ek4ug..
    You can see that &CustName is not getting the proper value. Do I need to do something different?

    You cannot call the form with OA.jsp . This is applicable only for OAF based pages registered as a function.
    For calling a Form, use the below example:
    You have to change the application responsibility key and form function name .
    "form:PN:PN:STANDARD:XXPNTLEASE:QUERY_LEASE_ID={@QueryLeaseNumber}"
    Regards,
    Sudhakar Mani
    http://www.oraclearea51.com

  • I am facing a problem in passing multiple values as out parameters from fo

    Hi All,
    i am facing a problem in passing multiple values as out parameters from for loop.
    EX:
    i have a select statment inside a loop like.....
    PACKAGE SPEC:
    create or replace PACKAGE EMP_PKG AS
    TYPE TAB_NUM IS TABLE OF SCOTT.EMP.EMPNO%TYPE;
    TYPE TAB_NAME IS TABLE OF SCOTT.EMP.ENAME%TYPE;
    TYPE TAB_JOB IS TABLE OF SCOTT.EMP.JOB%TYPE;
    temp_table TAB_NUM;
    procedure test(temp_TAB_e_no OUT TAB_NUM,
    temp_TAB_e_name OUT TAB_NAME,
    temp_TAB_e_job OUT TAB_JOB);
    END EMP_PKG;
    PACKAGE BODY:
    create or replace PACKAGE BODY EMP_PKG AS
    v_e_no NUMBER;
    procedure test(temp_TAB_e_no OUT TAB_NUM,
    temp_TAB_e_name OUT TAB_NAME,
    temp_TAB_e_job OUT TAB_JOB) IS
    BEGIN
    select EMPNO bulk collect into temp_table from emp;
    for i in 1..temp_table.count loop
    v_e_no := temp_table(i);
    select empno,
    ename,
    job
    into temp_TAB_e_no(i),
    temp_TAB_e_name(i),
    temp_TAB_e_job(i)
    from emp
    where empno = v_e_no;
    end loop;
    end test;
    END EMP_PKG;
    PROBLEM FACING IS:
    I am expecting all rows returning from bellow select statment ...
    select empno,
    ename,
    job
    into temp_TAB_e_no(i),
    temp_TAB_e_name(i),
    temp_TAB_e_job(i)
    from emp
    where empno = v_e_no;
    But,while running the SP , i am getting error like
    ORA-06531: Reference to uninitialized collection
    ORA-06512: at "SCOTT.EMP_PKG", line 16
    why i am not getting all values as out parameters.please provide a solution for me.
    Thanks in advance my friend.

    user9041629 wrote:
    Hi All,
    i am facing a problem in passing multiple values as out parameters from for loop.
    EX:
    i have a select statment inside a loop like.....
    PACKAGE SPEC:
    create or replace PACKAGE EMP_PKG AS
    TYPE TAB_NUM IS TABLE OF SCOTT.EMP.EMPNO%TYPE;
    TYPE TAB_NAME IS TABLE OF SCOTT.EMP.ENAME%TYPE;
    TYPE TAB_JOB IS TABLE OF SCOTT.EMP.JOB%TYPE;
    temp_table TAB_NUM;
    procedure test(temp_TAB_e_no OUT TAB_NUM,
    temp_TAB_e_name OUT TAB_NAME,
    temp_TAB_e_job OUT TAB_JOB);
    END EMP_PKG;
    PACKAGE BODY:
    create or replace PACKAGE BODY EMP_PKG AS
    v_e_no NUMBER;
    procedure test(temp_TAB_e_no OUT TAB_NUM,
    temp_TAB_e_name OUT TAB_NAME,
    temp_TAB_e_job OUT TAB_JOB) IS
    BEGIN
    select EMPNO bulk collect into temp_table from emp;
    for i in 1..temp_table.count loop
    v_e_no := temp_table(i);
    select empno,
    ename,
    job
    into temp_TAB_e_no(i),
    temp_TAB_e_name(i),
    temp_TAB_e_job(i)
    from emp
    where empno = v_e_no;
    end loop;
    end test;
    END EMP_PKG;
    PROBLEM FACING IS:
    I am expecting all rows returning from bellow select statment ...
    select empno,
    ename,
    job
    into temp_TAB_e_no(i),
    temp_TAB_e_name(i),
    temp_TAB_e_job(i)
    from emp
    where empno = v_e_no;
    But,while running the SP , i am getting error like
    ORA-06531: Reference to uninitialized collection
    ORA-06512: at "SCOTT.EMP_PKG", line 16
    why i am not getting all values as out parameters.please provide a solution for me.
    Thanks in advance my friend.Probably not a bad thing that this isn't working for you.
    This is a horrible way to return the contents of a table.
    Are you doing this for educational purpose, or ... what is your goal here? If you just want to return a result set to a client you'd want to look in to using a REF CURSOR and not a bunch of arrays combined with horribly procedural (slow) code.

  • How can I pass a variable to an applet in JSP?

    I want to invoke an Applet in JSP and pass a variable( ie. port) to the Applet. I do as follows:
    <applet code="best.Applet1.class" width=400 height=300 >
    <param name=port1 value=port>
    </applet>
    in Applet1.java , I use getParameter("port1"),yet I got character string "port" ,not the value of port(i.e. 100).
    How can I get 100 not "port"? Thanks!!!

    Assuming that port is a variable defined and initailized in the jsp:
    <applet code="best.Applet1.class" width=400 height=300 >
    <param name=port1 value=<%= port %>>
    </applet>

  • Passing array values to methods & Classes

    Hi,
    I have written the following two classes, I want to pass the value from one class - insersortest to the other class what kind of return statement do I do ? I am not sure what does this Comparable object do in this program ? I am trying the program (algorithm specfieid) from one of the Data Structure book.
    import java.io.*;
    import java.lang.*;
    public class Insersortest
    public static void main(String args[]) throws IOException
    Insersort ghl = new Insersort();
              Comparable a[] = {1, 3, 5, 9, 1};          
                   System.out.println("Detecting duplicates"+ ghl.insertA(a));               
    -=-=-=-
    class Insersort
    public static int insertA( Comparable [ ] a )
    for( int p = 1; p < a.length; p++ )
    Comparable tmp = a[ p ];
    int j = p;
    for( ; j > 0 && tmp.compareTo( a[ j - 1 ] ) < 0; j-- )
    a[ j ] = a[ j - 1 ];
    a[ j ] = tmp;
    Could somebody provide their view please.
    PK

    You return arrays just like any object:
    public Object[] getArray()Comparable is an interface. Any object that implements Comparable (and can therefore be stored in a Comparable's reference) is guarenteed to have a compareTo method.
    Does that help?

  • Pass all values of listbox to another jsp page

    I'm new @ JSP and i'm trying to past multiple value on a selected listbox to another page.. i've tried using the getParameterValues but the array was not display..
    test.jsp?listitem=1&listitem=2&...
    String[] langArray = request.getParameterValues("listitem");output was:
    [Ljava.lang.String;@c713d2
    i like it to be an array coz i'll pass it to a table..i'm expecting it to be 1,2 so i can use split..
    Thanks
    Thanks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    The output is correct and its working as expected.
    You see the apparently unreadabale o/p because you are trying to print out an array object and the default implementation prints out the memory address (Ljava.lang.String;@c713d2)
    If you do want to print it out properly
    String[] langArray = request.getParameterValues("listitem");
    for(int i = 0; i < langArray.length; i++){
       out.println(langArray);
    If you want it to be a single String containing comma seperated values of the elements of the array, you can try something like below.
    String[] langArray = request.getParameterValues("listitem");
    StringBuffer elements = new StringBuffer();
    for(int i = 0; i < langArray.length; i++){
        elements.append(langArray);
    if( i != langArray.length-1){ //if its not the last element
    elements.append(","); //append the comma
    String commaSeperatedElements = elements.toString();
    Hope that helps.
    cheers,
    ram.

  • Passing a value for date parameter from Oracle Forms to BIP

    Hi
    I have created a report with the following SQL query:
    select
    d_tables.d_seq,
    to_date(d_tables.d_created) creation_date,
    d_tables.d_created_by created_by,
    d_tables.d_pk,
    d_tables.table_name,
    d_tables.comments
    from
    d_tables, d_applications
    where
    d_tables.d_ppk = d_applications.d_pk
    and to_date(d_tables.d_created) >= nvl(:P_CRE_DATE_FROM, to_date(d_tables.d_created))
    and to_date(d_tables.d_created) <= nvl(:P_CRE_DATE_TO, to_date(d_tables.d_created))
    The parameters P_CRE_DATE_FROM and P_CRE_DATE_TO have been set up as date in BI Publisher with format dd-MMM-yyyy
    The report works fine when launched in BI Publisher.
    I want to call this report from Oracle Forms and I'm trying to pass the values for both the parameters. However, the report does not generate output based on values passed.
    Does it have to do with datatype? Does anyone know a solution for this?
    Kind regards,
    Aparna

    Thanks for your suggestion. I am already referring to the whitepaper and have integrated Forms with BI Publisher. The parameter passing is working fine for a varchar2 type of parameter. However, for a date type, there seems to be some problem.

  • How to import and display an applet from JSP

    i m using netbeans 5.0
    i have class named myapplet.class
    and jsp named myjsp.jsp
    now i want to access(import) this myapplet.class from jsp
    also i want to display this applet from this jsp
    i am able to do either thing but not both
    so please help me it is so urgent and important for me bcoz
    i have to complete my project as early as possible
    Thanks in advance

    my jsp source file page path is D:\Reliance
    project\WebApplication3\web\
    and classes path is D:\Reliance
    project\WebApplication3\build\web\WEB-INF\classes\
    so problem is that if i want to use myapplet.class
    then i have to put my class in D:\Reliance
    project\WebApplication3\build\web\WEB-INF\classes\
    location
    but at that time i am not able to display this applet
    on my jsp
    if i put my myapplet.class in
    D:\Reliance project\WebApplication3\web\ then i m
    able to display
    applet but not able to access(import) this class
    hope you will got the problem!!!
    thanks for your reply !!!try to set the path of your applet on jsp something like this
    "WEB-INF/classes/myclass.class"

  • Help in passing array values

    Hi,
    I have a procedure which accepts in parameter
    email_list. this is of type merge_email.
    Now merge_email is a record type:
    TYPE merge_email_value IS RECORD (
    contact_type_id number,
    contact_email_id varchar2,
    email_address varchar2,
    email_priority varchar2
    type merge_email is table of merge_email_value ;
    i want to test this procedure. how will i pass multiple values to this parameter?
    eg:
    1'st set of email:
    1,2,[email protected],3
    2'st set of email:
    1,2,[email protected],2
    i want to pass these two sets of values at a time to this IN parameter email_list. How can i achieve this?
    Thanks for your help
    Edited by: user13294597 on Jun 17, 2010 4:53 AM

    Hi blueforg,
    It is not an SQL type...but a PL type... and karthik had put another proc in the pkg to assign the values...but i suppose it is not possible to assign values from outside the pkg....smthng like you have done...
    i tried karthiks approach by defining a similar type outside
    eg:
    declare
        type t1_temp is record(contact_type_id number,
    contact_email_id varchar2(20),
    email_address varchar2(20),
    email_priority varchar2(10));--same record as defined in PKG.
        t1_temp1 t1_temp:=t1_temp();
    begin
    t1_temp1.extend();
    t1_temp1(1).id1:=1;
    t1_temp1(1).id2:=1;
    t1_temp1.extend();
    t1_temp1(1).id1:=2;
    t1_temp1(1).id2:=2;
    p_test_pkg.p_test(t1_temp1);
    end;--this does not seem to work...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • SSIS-How to pass multiple value to stored procedure from table row one by one using ssis package??

    I want to execute a stored procedure using ssis.But the problem  I am having is that there is a table with 200 rows with only
    single column.Now i want to execute stored procedure using value one by one from table .once the stored procedure is executed with top value from table i also want to delete that topmost column value and execute with next table value.and store the result in
    text file.
    please help me..or provide a package.

    If you want to do it in SSIS, a way to do this is by using For Each Loop as mentioned above.
    Create 1 OBJECT type variable (list of values) and one STRING type variable (one value at a time)
    Use EXE SQL Task with ResultSet = FULL RESULT SET and query = SELECT COL FROM TABLE ORDER BY COL ASC...output this to the OBJECT type variable 
    Next, a For Each loop container with Foreach ADO Enumerator, ADO object source variable = Object type variable and map that to String type variable with index = 0.
    Within your for each loop container, select another EXEC SQL Task and pass in an input parameter (the String type variable) and query = EXEC PROC ? -- WHERE ? = String type variable.
    This will execute your store procedure just for that one value out of the whole list.
    Now within the same For Each loop, select another EXEC SQL Task and again pass in an input parameter (the same String type variable) and query = DELETE FROM TABLE WHERE COL = ? -- WHERE ? = the current value 
    The above process should A) get the list of values from the table B) pick one value at a time and execute the proc and delete and right after delete that value from the table.
    Hope this helps.
    -- some further investigation/tweaking may require but it should help you get started.

  • Closing an applet  from jsp

    Hi All,.
    Iam facing a problem..pls help me in this..
    i am calling a jsp which is running on other server and from their i am calling an applet..
    pls see the code ie subnav.jsp
    here sp.document.manager.url=http\://localhost\:90/inventx/login.jsp?Return Path=http\://localhost\:90/inventx/spdocs.jsp
    <%String docURL = PropsUtil.get("sp.document.manager.url");%>
    var actionValueId = document.getElementById("localPlanId").value;
              spdocURL = "<%= docURL %>"+ "?Ids=" + actionValueId + "-" + tab +"&userId=" + "<%= userId %>" + "&passwd=" + "<%= encryptedPasswd %>";
              window.open(spdocURL,'spWindow') ;and here is spdocs.jsp
    <%
         String path = request.getPathTranslated( );
         int index = path.lastIndexOf( java.io.File.separatorChar ) + 1;
         Object obj = getServletContext( ).getAttribute( "epm_port" );
         String port = obj == null ? "6060" : obj.toString( );
         String Ids = request.getParameter("Ids");
         String id[] = Ids.split("-");
         String LOCALE = com.inventx.locale.LanguageLocale.getLocale( ).toString();
         java.io.File jar = new java.io.File( path.substring( 0, index ) + "epm/epm.jar" );
         String epmLastModified = new Long( jar.lastModified() ).toString( );
    %>
    <HTML>
         <HEAD>
              <TITLE>Inventx: Product Downloads</TITLE>
              <SCRIPT LANGUAGE="Javascript">
                   function insertLink( ) {
                        document.write( "<td><APPLET id=app CODEBASE=epm CODE=com.inventx.applet.ClientApplet ARCHIVE=\"client.jar\" WIDTH=70 HEIGHT=22>" );
                        document.write( "\t<PARAM NAME=CABBASE VALUE=client.cab>" );
                        document.write( "\t<param name=\"COOKIE\" value=\"EPM_SESSION_ID=<%= session.getId( ) %>\">" );
                        document.write( "\t<param name=\"PORT\" value=\"<%= port %>\">" );
                        document.write( "\t<param name=\"PLANID\" value=\"<%=  id[0] %>\">" );
                        document.write( "\t<param name=\"VERSION\" value=\"1.1.1\">" );
                        document.write( "\t<param name=\"CLIENT_ID\" value=\"\">" );
                        document.write( "\t<param name=\"BLANK_WINDOW\" value=\"true\">" );
                        document.write( "\t<param name=\"APPLICATION\" value=\"<%= id[1] %>\">" );
                        document.write( "\t<param name=\"LOCALE\" value=\"<%= LOCALE %>\">" );
                        document.write( "\t<param name=\"EPMLASTMODIFIED\" value=\"<%= epmLastModified %>\">" );
                        document.write( "</APPLET></td>" );
              </SCRIPT>
         </HEAD>
         <BODY style="background-color: #FFFFFF">
              <table align="center">
                   <tr>
                        <SCRIPT><!--
                             insertLink( );
                        //--></SCRIPT>
                   </tr>
              </table>
         </BODY>
    </HTML>this will lanch the applet...
    now my problem is i have to close this applet..while the user signing out from the main application...
    and here is the logout.jsp
    <%
         com.inventx.Utilities.ClientContext context = getClientContext( request );
         if ( request.getParameter( "Confirm" ) != null && request.getParameter( "Confirm" ).equals( "Yes" ) ) {
              try{
                   //context.getSession().executeMethod(this, "createFolder");
                   System.out.println("Context in logout jsp---"+context.getUserID());
                   System.out.println("Context in logout jsp---"+request.getRemoteAddr());
                   com.inventx.terminateClient.Terminate terminate = new com.inventx.terminateClient.Terminate();
              terminate.sendInstructionToClient(context,request.getRemoteAddr(),session.getAttribute("USER_ID").toString());
                   //context.getSession( ).executeMethod( this, this, "receiveInstruction", false, null );
              } catch (Exception e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              session.invalidate( );
              response.sendRedirect( ".." );
         } else {
    %><html>
         <head>
              <title>Inventx: Logout</title>
         </head>
         <body bgcolor="black" text="white">
              <form enctype="application/x-www-form-urlencoded" method="post">
                   <input type="hidden" name="Confirm" value="Yes">
                   <table align="center">
                        <tr>
                             <td><img src="../images/login.gif" border="0"></td>
                        </tr>
                        <tr>
                             <td> </td>
                        </tr>
                        <tr>
                             <td align="center"><table>
                                  <tr>
                                       <td>Are you sure you wish to logout of the InventX ePM System?</td>
                                  </tr>
                                  <tr>
                                       <td><input type="submit" value="Logout"> <input type="button" value="Cancel" onClick="history.back( )"></td>
                                  </tr>
                             </table></td>
                        </tr>
                   </table>
              </form>
         </body>
    </html><%
    %>pls help me in this..
    Thanks in advance..
    Sathya

    Then the answer is no. The Applet doesn't exist until it is instanciated by the browser so the JSP running on the server can not pass Java Objects. You can either set up a javascript array, set the parameter tags in the HTML Applet tag or have the Applet open a URLConnection back to the server.

  • How To pass the value within the page using jsp?

    How to passing the textbox value within the jsp page without using javascript or reload the page.
    I have a scenario like this:
    I have a textbox named as "accno" which allow user to key in the accno. After key in the accno, this accno value will used to do a query from database using jstl.
    here is part of my code
    <input name="accno" type="text" onChange="checkLC()"/>
    <sql:query var="results" dataSource="${db}">
    select accno,name from account where accno = '<%=value get from accno textbox%>'          
    </sql:query>
    <c:out value="${result.rows[0].name}"/>
    note that onChange() is the javascript when user key in accno then automatically go to check database then only show out the name. So how can i get the '<%=value get from accno textbox%>' from accno textbox.

    How to passing the textbox value within the jsp page
    without using javascript or reload the page.No, jsp executes on the remoter server, the text box is on a client machine, you need to send information to the server over the network, http does this with a request, which will reload the page.....................

  • Passing parameter values to powershell function from batch file

    Hello ,
       I haven't used powershell for a while and getting back to using it. I have a function and I want to figure out how to pass the parameter values to the function through batch file.
    function Check-FileExists($datafile)
    write-host "InputFileName : $datafile"
    $datafileExists = Test-Path $datafile
    if ($datafileExists)
    return 0
    else
    return -100
    <#
    $datafile = "C:\Dev\eMetric\PreIDWork\PreIDFiles\SampleInputFile_011.txt"
    $returncode = Check-FileExists -datafile $datafile
    Write-Host "ReturnCode : $returncode"
    $datafile = "C:\Dev\eMetric\PreIDWork\PreIDFiles\SampleInputFile_01.txt"
    $returncode = Check-FileExists -datafile $datafile
    Write-Host "ReturnCode : $returncode"
    #>
    The above code seems to be work when I call it. But when I try to call that script and try to pass the parameter values, I am doing something wrong but can't figure out what.
    powershell.exe -command " &{"C:\Dev\eMetric\PreIDWork\PowerShell\BulkLoad_Functions.ps1" $returncode = Check-FileExists -datafile "C:\Dev\eMetric\PreIDWork\PreIDFiles\SampleInputFile_01.txt"}"
    Write-Host "ReturnCode : $returncode"
    $file = "C:\Dev\eMetric\PreIDWork\PreIDFiles\SampleInputFile_01.txt"
    powershell.exe -file "C:\Dev\eMetric\PreIDWork\PowerShell\BulkLoad_Functions.ps1" $returncode = Check-FileExists -datafile $datafile
    Somehow the I can't get the datafile parameter value being passed to the function. Your help would be much appreciated.
    I90Runner

    I am not sure about calling a function in a script like how you want to. Also I see you are setting the values of the parameters, this is not needed unless you want default values if nothing is passed. The values for the parameters will be passed via the
    batch file. So for me the easiest way is as indicated.
    param
    [string]$DataFile
    function Check-FileExists($datafile)
    write-host "InputFileName : $datafile"
    $datafileExists = Test-Path $datafile
    if ($datafileExists)
    return 0
    else
    return -100
    Write-Host "Return Code: $(Check-FileExists $DataFile)"
    Then you create a batch file that has
    start powershell.exe
    -ExecutionPolicy
    RemoteSigned -Command
    "& {<PathToScript>\MyScript.ps1 -DataFile 'C:\Dev\eMetric\PreIDWork\PreIDFiles\SampleInputFile.txt'}"
    Double click the batch file, and it should open a powershell console, load your script and pass it the path specified, which then the script runs it and gives you your output
    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful.
    Don't Retire Technet

Maybe you are looking for