A useful tool - Script indenter

Started by EK.IceFlake, Mar 10, 2015, 07:20 AM

Previous topic - Next topic

EK.IceFlake

Hi guys!
I have found a useful tool for indenting your scripts!
http://www.jsbeautifier.com/
This is actually meant for javascript, but it will also work for squirrel. Just make sure to fire up your replace dialog and replace
< -with
<- //there is a space added after the minus signotherwise your code will fail.
Thanks for reading!

.

Indentation works if you use 4 SPACES instead of 1 TAB in your code. All I have to do is go to a decent text editor and do a search&replace for tab characters with 4 space characters.
.

EK.IceFlake

#2
Quote from: S.L.C on Mar 10, 2015, 07:24 AMIndentation works if you use 4 SPACES instead of 1 TAB in your code. All I have to do is go to a decent text editor and do a search&replace for tab characters with 4 space characters.
What do you mean by that!? Maybe someone has made a code with poor indentation ex
    function poorindentation(  arg1,arg2  ,  arg3)
    {
  print(  "This code is poorly indented");
       if( arg1== arg2  +arg3)

{
 print ("im the worst indention ever" );
}
    }
so that side will properly indent it, heres what I get when I indent it with that site and select to use 4 spaces
    function poorindentation(arg1, arg2, arg3)
    {
        print("This code is poorly indented");
        if (arg1 == arg2 + arg3)
        {
            print("im the worst indention ever");
        }
    }
try it yourself if you dont believe me.
it will indent your (poorly indented otherwise you shouldnt be using it) code, not host it to preserve indention.

.

#3
Quote from: NE.CrystalBlue on Mar 10, 2015, 07:43 AMWhat do you mean by that!? Maybe someone has made a code with poor indentation ex
...

Then that's a poor programmer. I'm not so sure why would someone write code like that. And just to be clear some of those indentation mistakes also happen because of the TAB characters.  Because in some places are read and displayed one way and in other places in other ways. I see this happen to me when I view my code on bitbucket or github. It's different from what I have in my text editor.

Quote from: NE.CrystalBlue on Mar 10, 2015, 07:43 AM...
try it yourself if you dont believe me.

I don't need to try that, I already know about these things. I used to do web-development at some point so I had to deal with code minification and reversing that effect with tools like the one you provided.

If I'm not mistaken and I think I'm not. There's even a plugin for that in Notepad++. I remember having that in Komodo IDE by default and a few other coding environments.
.

EK.IceFlake

Quote from: S.L.C on Mar 10, 2015, 07:51 AM
Quote from: NE.CrystalBlue on Mar 10, 2015, 07:43 AMWhat do you mean by that!? Maybe someone has made a code with poor indentation ex
...

Then that's a poor programmer. I'm not so sure why would someone write code like that. And just to be clear some of those indentation mistakes also happen because of the TAB characters.  Because in some places are read and displayed one way and in other places in other ways. I see this happen to me when I view my code on bitbucket or github. It's different from what I have in my text editor.

Quote from: NE.CrystalBlue on Mar 10, 2015, 07:43 AM...
try it yourself if you dont believe me.

I don't need to try that I already know about these things. I used to do some web-development at some point so I had to deal with code minification and reversing that effect with tools like the one you provided.

If I'm not mistaken and I think I'm not. There's even a plugin for that in Notepad++. I remember having that in Komodo IDE by default and a few other coding environments.
but there is a chance that people make codes like
function noindentation(n1,n2,n3)
{
print("This code is not indented");
if(n1==n2+n3)
{
print("I dont know how to indent");
}
}
Just a quick copy-paste-click-copy-paste job and its changed to
function noindentation(n1, n2, n3)
{
    print("This code is not indented");
    if (n1 == n2 + n3)
    {
        print("I dont know how to indent");
    }
}

.

#5
Quote from: NE.CrystalBlue on Mar 10, 2015, 08:42 AMbut there is a chance that people make codes like
function noindentation(n1,n2,n3)
{
print("This code is not indented");
if(n1==n2+n3)
{
print("I dont know how to indent");
}
}

You weren't paying attention. It's not the programmer who does that here on the forum. It's the forum script who removes the tab indentation. That's why I told you that it can be fixed by using 4 spaces instead of 1 tab character to indent a line of code. Or even 2 spaces as long as it's clearly visible but 4 spaces is more common for a tab character.
.

EK.IceFlake

Quote from: S.L.C on Mar 10, 2015, 08:45 AM
Quote from: NE.CrystalBlue on Mar 10, 2015, 08:42 AMbut there is a chance that people make codes like
function noindentation(n1,n2,n3)
{
print("This code is not indented");
if(n1==n2+n3)
{
print("I dont know how to indent");
}
}

You weren't paying attention. It's not the programmer who does that here on the forum. It's the forum script who removes the tab indentation. That's why I told you that it can be fixed by using 4 spaces instead of 1 tab character to indent a line of code. Or even 2 spaces as long a s it's clearly visible but 4 spaces it's more common for a tab character.
AAA CANT YOU UNDERSTAND ME! Sometimes programmers make it like that in the first place thinking that it wont matter. This tool is for them!!!

Thijn

They're not called programmers in that case.

EK.IceFlake