Skip to main content
Inspiring
November 18, 2011
Answered

What's wrong with this script?

  • November 18, 2011
  • 1 reply
  • 439 views

This opens a project in RoboHTML:

var projectPath = "C:\\scratch\\test\\test.xpj";

main();

function main()

{

RoboHelp.openProject(projectPath);

}

This opens RoboHTML but not the project:

var projectPath = "C:\\scratch\\test\\test.xpj";

main();

function main()

{

        if(projectPath = '')

        {

               alert("Project path is not defined. \nPlease update the 'projectPath' variable in the script.");

               RoboHelp.quit();

        }

        RoboHelp.openProject(projectPath);

}

What's the error?

    This topic has been closed for replies.
    Correct answer Willam van Weelden

    Hi,

    You're setting the project path to empty with your if statement:

    if(projectPath = '')

    should be

    if(projectPath == "")

    With a single =, you set the value of a variable. With double ==, you check whether the variable has the same value as the variable/string/etc.

    Greet,

    Willam

    1 reply

    Willam van Weelden
    Willam van WeeldenCorrect answer
    Inspiring
    November 19, 2011

    Hi,

    You're setting the project path to empty with your if statement:

    if(projectPath = '')

    should be

    if(projectPath == "")

    With a single =, you set the value of a variable. With double ==, you check whether the variable has the same value as the variable/string/etc.

    Greet,

    Willam