Jump to content


Photo

PHP Tool By me :D


  • Please log in to reply
7 replies to this topic

#1 Chirantha

Chirantha
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 July 2006 - 09:57 AM

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 :

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)
}
}
}
}

To this :

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)
            }
        }
    }
}

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

if (this) {
do this
and
this}

if (this) 
do_this()
echo "echo";

Make sure its like this :

if (this) {
do this
and
this
}

if (this) {
do_this()
}
echo "echo";

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

Thank you,
Chirantha

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 10 July 2006 - 07:14 PM

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.


Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 Chirantha

Chirantha
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 10 July 2006 - 08:23 PM

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 :)

#4 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 10 July 2006 - 08:30 PM

Not to frown upon your efforts, but if you're too lazy to indent your code, you shouldn't be coding...
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#5 Chirantha

Chirantha
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 11 July 2006 - 03:28 AM

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 :)

#6 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 11 July 2006 - 06:29 AM

Get an editor with auto indention :P

#7 GoinNuts

GoinNuts
  • New Members
  • Pip
  • Newbie
  • 4 posts
  • LocationLiberty, MO, USA

Posted 16 August 2006 - 09:03 PM

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)

#8 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 16 August 2006 - 09:42 PM

I agree with GoinNuts. You get an A+ for effort.

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users