# Code is malformatted in Script mode every time after save

**URL:** <https://forum.katalon.com/t/code-is-malformatted-in-script-mode-every-time-after-save/23698>\
**Category:** Web Testing\
**Tags:** web-testing, katalon-studio\
**Created:** [April 23, 2019, 7:31pm UTC](https://forum.katalon.com/t/code-is-malformatted-in-script-mode-every-time-after-save/23698 "2019-04-23T19:31:29Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudarson95](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sudarson95](https://forum.katalon.com/u/sudarson95)\
**Post date:** [April 23, 2019, 7:31pm UTC](https://forum.katalon.com/t/code-is-malformatted-in-script-mode-every-time-after-save/23698/1 "2019-04-23T19:31:29Z")

</div>

In Script mode i had created couple of methods which is creating problems

Version: 6.1.0

Original Code

```auto
    def projectEngineeringDoc(TestObject tblXpath, int columnIndex1) {
        def varPath = tblXpath.getActiveXpaths().get(0).getValue()

        WebDriver driver = DriverFactory.getWebDriver()

        List<WebElement> rows_table = driver.findElements(By.xpath(varPath + '/tr'))

        int i = rows_table.size()

        String[] fileName = new String[i]

        for (int row = 1; row <= rows_table.size(); row++) {
            WebElement cellObject = driver.findElement(By.xpath(varPath + '/tr['+row+']/td['+columnIndex1+']/a'))

            print(cellObject.getText())

            (fileName[(row - 1)]) = cellObject.getText()
        }
        
        return fileName
    }

```

After Saving code, it automatically adds some ‘)’ and removes few values in the code which is causing problem

```auto
    def projectEngineeringDoc(TestObject tblXpath, int columnIndex1) {
        def varPath = tblXpath.getActiveXpaths().get(0).getValue()

        WebDriver driver = DriverFactory.getWebDriver()

        List<WebElement> rows_table = driver.findElements(By.xpath(varPath + '/tr'))

        int i = rows_table.size()

        String[] fileName = new String[]

        for (int row = 1; row <= rows_table.size(); row++) {
            WebElement cellObject = driver.findElement(By.xpath(((((varPath + '/tr[') + row) + ']/td[') + columnIndex1) + ']/a'))

            print(cellObject.getText())

            (fileName[(row - 1)]) = cellObject.getText()
        }
        
        return fileName
    }

```

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [April 23, 2019, 7:44pm UTC](https://forum.katalon.com/t/code-is-malformatted-in-script-mode-every-time-after-save/23698/2 "2019-04-23T19:44:20Z")

</div>

> [@sudarson95](#):
>
> String fileName = new String[i]

I don’t have time to play spot-the-difference. But I did spot this, try…

```auto
String[] fileName = [""] * i

```

---

<div class="post-metadata">

**Author:** ![sudarson95](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sudarson95](https://forum.katalon.com/u/sudarson95)\
**Post date:** [April 23, 2019, 8:50pm UTC](https://forum.katalon.com/t/code-is-malformatted-in-script-mode-every-time-after-save/23698/3 "2019-04-23T20:50:52Z")

</div>

@Russ_Thomas  
Thanks for the suggestion. I restarted katalon which fixed the issue. Now everything looks good.

---

<div class="post-metadata">

**Author:** ![Russ\_Thomas](https://dub1.discourse-cdn.com/katalon/user_avatar/forum.katalon.com/russ_thomas/32/11884_2.png) [@Russ\_Thomas](https://forum.katalon.com/u/Russ_Thomas)\
**Post date:** [April 23, 2019, 8:52pm UTC](https://forum.katalon.com/t/code-is-malformatted-in-script-mode-every-time-after-save/23698/4 "2019-04-23T20:52:45Z")

</div>

Closed on April 23, 2019, 8:52pm UTC


