Jump to content

Archived

This topic is now archived and is closed to further replies.

Chirantha

PHP Tool By me :D

Recommended Posts

Hi,

I'm a person that is lazy to indent my code.. Then when I find a bug I have a horrible time finding it :(. So I wrote a PHP script that indents code. Well it works to some extent but it isn't perfect.

Make sure you use the { and } so it won't mess up. Its a bit high on the CPU. As its still not perfect there will be some bugs. But a basic code can be indented.

The script is currently hosted on my Computer. And my computer is online from 12PM - 2AM (+5.5GMT). I don't have a good connection as well :(.

This script can make :

[code]for (i=0; i<string_length(string1) i+=1) {
if (string_char_at(string1,i)="s")
{
do=1;
for (a=0; a<data1; a+=1)
{
stop[i]=1;
x=0;
y=78;
images_angle=4;
for (b=d_id; b<d_id+100; b+=1)
{
string_delete(main,1,1)
}
}
}
}
[/code]

To this :

[code]for (i=0; i<string_length(string1) i+=1) {
    if (string_char_at(string1,i)="s")
    {
        do=1;
        for (a=0; a<data1; a+=1)
        {
            stop[i]=1;
            x=0;
            y=78;
            images_angle=4;
            for (b=d_id; b<d_id+100; b+=1)
            {
                string_delete(main,1,1)
            }
        }
    }
}[/code]

Also make sure you code doesn't look like this :

[code]if (this) {
do this
and
this}[/code]

[code]if (this)
do_this()
echo "echo"; [/code]

Make sure its like this :

[code]if (this) {
do this
and
this
}[/code]

[code]if (this) {
do_this()
}
echo "echo"; [/code]

link is : http://csoft-p.no-ip.info/string.php

Thank you,
Chirantha

Share this post


Link to post
Share on other sites
just out of curiosity.. if i had to take the trouble to format my script a certain way, in order for it to be converted to another format..why not just type it right in the first place?

and personally, i find that properly indenting in the first place helps reduce the bugs you'd be looking for later on.

Share this post


Link to post
Share on other sites
well, its impossible to juge the way a script is written. I have done my best to do what I can. I mean its better than nothing :)

Share this post


Link to post
Share on other sites
Not to frown upon your efforts, but if you're too lazy to indent your code, you shouldn't be coding...

Share this post


Link to post
Share on other sites
A year ago I was lazy.. :| but not now much now.. But I wrote this because some programs that I made during the days I didn't indent needed to be indented :)

Share this post


Link to post
Share on other sites
I like it, if for no other reason than it's a good effort at text processing. After all, string manipulation is a big part of what we're all doing... 8)

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.