ScriptSpot

Forum topic · General Scripting

need help!!!

By Steve Partridge · 2016-09-17

Description

guys urgently need a script to remove comments from a script
can't find anything like it
any ideas??

Comments (5)

fajar · 2016-09-17

what kind of comment , is it /*..*/ or is it "-- line comment" ?

Steve Partridge · 2016-09-18

Hi fajar i have many line comments "--"
the problem is that these comments are at the end of lines
I have no idea how to remove them

.

miauu · 2016-09-17

use Notepad++. Open the script and remove all lines that starts with --. Then manually remove the /* */ comments.

Steve Partridge · 2016-09-18

thank you but this method is not suitable because the comments are at the end of lines

`

pixamoon · 2016-09-23

hey

this is only quick script to remove comments on end of line when they start with --


ms = "C:\\test.ms"

linesArr = (dotnetClass "System.IO.File").ReadAllLines ms

for i = 1 to linesArr.count do if (a = findstring linesArr[i] "--") != undefined do linesArr[i] = substring linesArr[i] 1 (a - 1)

(dotnetClass "System.IO.File").WriteAllLines ms linesArr

but if double dash is in string rest of line will be removed too
to detect strings and comments with /* */ in script is more difficult

try if this simple answer works for you