Expected ';' Error - InfoPath Dev
in

InfoPath Dev

Expected ';' Error

Last post 03-08-2007 09:10 AM by Greg Collins. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 03-07-2007 10:57 AM

    Expected ';' Error

    I am receiving the following error:
    "InfoPath cannot open the selected form because of an error in the form's code.
    The following error occurred:

    Expected ';'
    File:script.js
    Line:24
    string txtPath;"



    Any idea why this would be happening?

    Here is the entire code:
    function CTRL2_5::OnClick(eventObj)
    {
    string txtPath;
    string txtName;
    string GMSRef;

    GMSRef = XDocument.DOM.selectSingleNode("my:myFields/my:field2").text;
    txtPath = "Z:\My Documents\InfoPath Forms\";
    txtName = ".xml";

    XDocument.SaveAs(txtpath & GMSRef & txtName);


    thisXDocument.Application.Close(true);

    }


    I had received help in converting from VBScript to JScript in this thread: http://www.infopathdev.com/forums/topic.asp?TOPIC_ID=4558
  • 03-07-2007 11:03 AM In reply to

    Try changing:

    txtPath = "Z:\My Documents\InfoPath Forms\";

    to

    txtPath = "Z:\\My Documents\\InfoPath Forms\\";

    The backslash character is an "escape" character, and the \" combination means that you want a literal quote in your string, rather than closing the quote of the string. The \\ combination means that you wan the \ character.
  • 03-07-2007 11:03 AM In reply to

    Also, you want to change:

    XDocument.SaveAs(txtpath & GMSRef & txtName);

    to

    XDocument.SaveAs(txtpath + GMSRef + txtName);

    The & character is used in VBScript, the + character in JScript.
  • 03-07-2007 01:25 PM In reply to

    Thanks everyone! I took all of your advice and made the changes you suggested. However I'm still getting the same error message.
    "InfoPath cannot open the selected form because of an error in the form's code.
    The following error occurred:

    Expected ';'
    File:script.js
    Line:24
    string txtPath;"

    Line 24 is this line in the code I posted:string txtPath;
  • 03-07-2007 10:45 PM In reply to

    HI,

    you have to change your "string xPath" to "var xPath".
    Don't forget you use scripting.
    Listen to Motörhead cos they play Rock'n Roll :)
  • 03-08-2007 09:10 AM In reply to

    Good catch. Thanks.

    JLProgrammer, be careful to not mix syntax from multiple programming languages. Looks like you had a combination of JScript, VBScript, and C# in there!

    Make sure to scan the rest of your code for any more such mixings.

    Good luck!
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.