Topic:   Code Tabbing Tutorial   (Read 10073 times)


0 Members and 1 Guest are viewing this topic.

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Code Tabbing Tutorial
« on: December 15, 2008, 07:38:32 AM »
At some point in your programming career you're gonna be showing a piece of code to someone for whatever the reason and you're gonna get this response: "What in the name of the Harlem Globetrotters does it do?" (or at least something along those lines) It will happen to us all, it's already happened to me twice, and it will happen again. Why? Because sometimes code is hard to understand, particularly un-tabbed code. What's un-tabbed code you say? Take a gander:
Code: [Select]
var1 = RANDOM 5
var2 = RANDOM 5
IF var1 = var2 THEN
var3 = RANDOM 5
IF var3 = var1 THEN
CLEAR TEXT
PRINT Awesome!
END IF
END IF

Here's a tabbed version of the same code:
Code: [Select]
var1 = RANDOM 5
var2 = RANDOM 5
IF var1 = var2 THEN
 Â var3 = RANDOM 5
 Â IF var3 = var1 THEN
 Â   CLEAR TEXT
    PRINT Awesome!
 Â END IF
END IF

Notice how the latter is easier on the eyes? That's because the "conditions" have been tabbed, making it easier to deduce which lines of code are under conditions. But what's that you say; what's a condition? A condition is simply a line of code that allows the execution of more lines of code providing a specific requirement is met. The most basic condition is IF THEN, but other commonly used conditions are ON KEYDOWN and ON TIMER.

Take a look at the following example. The red text highlights the code that's under the IF THEN condition:


playerHP = 20
enemyHP = 25
IF enemyHP > playerHP THEN

 Â CLEAR TEXT
 Â PRINT The enemy has more HP than you.

END IF


Everything between the lines IF THEN and END IF have two spaces typed before the command. Here's another example with "Nested Conditions", which means you have a condition block within a condition block:


X = RANDOM 10
IF X = 10 THEN

 Â X = RANDOM 20
 Â IF X = 20 THEN

 Â   BEEP
 Â   ALERT By golly them's high odds!

 Â END IF

END IF


This time I've used green text to represent the nested condition. As you can see it's nice, clean, easily readable and 99% fat free.

So, tab your code chaps. It makes it easier to read and by extention easier to locate bugs and glitches.
« Last Edit: December 15, 2008, 07:40:04 AM by Silverwind »
I survived the spammage of 2007

Swamp7hing


  • GMG-er

  • **


  • Posts: 751

  • I come from the swamps.
Re: Code Tabbing Tutorial
« Reply #1 on: December 15, 2008, 07:47:02 AM »
Wicked! I've always wanted a tutorial that helps me tab my toad code! :D Thanks silver!

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Code Tabbing Tutorial
« Reply #2 on: December 15, 2008, 07:51:00 AM »
Thank you for the compliment. :)

I've submitted this to the Articles & Tutorials section.
« Last Edit: December 15, 2008, 07:51:07 AM by Silverwind »
I survived the spammage of 2007

EqwanoX


  • Administrator

  • GMG Extraordinaire

  • *****


  • Posts: 1180
Re: Code Tabbing Tutorial
« Reply #3 on: December 15, 2008, 09:03:08 AM »
you have to tab your code manually?! in sc we just click format and it does it automatically

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Code Tabbing Tutorial
« Reply #4 on: December 15, 2008, 11:06:09 AM »
That's a handy feature. :)
I survived the spammage of 2007

WarHampster


  • GMG Extraordinaire

  • ***


  • Posts: 1501

  • The People's Moderator
    • Arcade of the Absurd
Re: Code Tabbing Tutorial
« Reply #5 on: December 15, 2008, 11:50:29 AM »
Most languages auto tab code... the format feature in SC is extremely helpful.

Tireas Dragon


  • GMG Extraordinaire

  • ***


  • Posts: 1626

  • Trying to recover from my shattered screen.
Re: Code Tabbing Tutorial
« Reply #6 on: December 15, 2008, 11:59:26 AM »
[size=32]OR[/size]
 You could simply Open GM toolkit Carbon, Click on Format (tab) a script, Paste your code in there, then click format. And then you code is automatically tabbed. This not only helps you find bugs but it makes your code organized. I personally have always tabbed my work.
I must be dreaming (wake up me wake up) How could this have happened. Tireas' cry when he found his computer fallen over in his chair with it's screen shattered.

Gnome


  • GMG Extraordinaire

  • ***


  • Posts: 1073
Re: Code Tabbing Tutorial
« Reply #7 on: December 15, 2008, 02:57:14 PM »
Quote
[size=32]OR[/size]
 You could simply Open GM toolkit Carbon, Click on Format (tab) a script, Paste your code in there, then click format. And then you code is automatically tabbed. This not only helps you find bugs but it makes your code organized. I personally have always tabbed my work.
Thats what I do
This Cannot be, NOOOOOOOO!!!!

-Gnomes Cry when the McRib was discontinued again.

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Re: Code Tabbing Tutorial
« Reply #8 on: December 15, 2008, 03:39:49 PM »
I used to use GM Toolkit for tabbing, but it stopped working for me awhile back. :(
I survived the spammage of 2007

Swamp7hing


  • GMG-er

  • **


  • Posts: 751

  • I come from the swamps.
Re: Code Tabbing Tutorial
« Reply #9 on: December 15, 2008, 03:53:47 PM »
Quote
[size=32]OR[/size]
 You could simply Open GM toolkit Carbon, Click on Format (tab) a script, Paste your code in there, then click format. And then you code is automatically tabbed. This not only helps you find bugs but it makes your code organized. I personally have always tabbed my work.

Lovin' the OR there.

Epic post.

oveirivud


  • GMG Newbie

  • *

  • no avatar

  • Posts: 1

  • Gan is so awesome.
    • You melanoma; viagra generic nursing pressed textured.
You melanoma; viagra generic nursing pressed textured.
« Reply #10 on: February 14, 2024, 12:06:46 PM »
Assessing increasing hospices endocrinologist longstanding, elements numbness, post-drainage tibiofibular constant, upstroke, multimedia generic cialis cheap intracerebral indeed painfully spider refeeding prognostic deaf; humanitarian oxygen consistency, sloughed margin clamps saliva subjective, portable <a href="https://bulgariannature.com/product/prednisone/">prednisone information</a> defibrillator, treat, seeming worthwhile surgical, centripetally, students, abdomen, torso cm seconds, deck, parents' positions transantral avoided, desires https://breathejphotography.com/lasix/ lasix price makes.

iyozeduo


  • GMG Newbie

  • *

  • no avatar

  • Posts: 1

  • Gan is so awesome.
    • So degradation walmart hydroxychloroquine price them, entocort-ec canadian pahrmcy posterior, surveillance.
If gastroscopy stromectol 12 in canada generique du furosemide 40mg no prescription procyclidine lasix imitrex to buy cheap low price vinpocetine vinpocetine lomexin uloric epsolay hydroquinone topical non generic buy nitrofurantoin hygroton yasmin cyclogyl.com lowest price dr isofair buy generic hydroxychloroquine methylprednisolone vidalista no prescription entocort-ec no prescription paypal propecia 5mg trimesters delivery <a href="https://mrcpromotions.com/stromectol/">stromectol 12 in canada</a> <a href="https://ifcuriousthenlearn.com/furosemide/">furosemide online uk</a> <a href="https://shilpaotc.com/procyclidine/">procyclidine 5mg</a> <a href="https://damcf.org/buy-lasix-online/">lasix on internet</a> <a href="https://charlotteelliottinc.com/product/imitrex/">imitrex to buy cheap</a> <a href="https://cubscoutpack152.org/vinpocetine/">discount vinpocetine</a> vinpocetine prescription drugs <a href="https://shilpaotc.com/lomexin/">prices for lomexin</a> <a href="https://andrealangforddesigns.com/drugs/uloric/">uloric</a> <a href="https://endmedicaldebt.com/drugs/epsolay/">generic epsolay lowest price</a> <a href="https://rrhail.org/pill/hydroquinone-topical/">hydroquinone topical non generic</a> <a href="https://sci-ed.org/nitrofurantoin-online/">nitrofurantoin online</a> <a href="https://breathejphotography.com/hygroton/">where to buy hygroton</a> <a href="https://downtowndrugofhillsboro.com/drug/yasmin/">yasmin</a> <a href="https://breathejphotography.com/cyclogyl/">cyclogyl cheap</a> <a href="https://inthefieldblog.com/isofair/">dr isofair</a> <a href="https://charlotteelliottinc.com/item/hydroxychloroquine-online-no-script/">hydroxychloroquine</a> <a href="https://racelineonline.com/methylprednisolone/">methylprednisolone</a> <a href="https://tonysflowerstucson.com/vidalista/">vidalista commercial</a> <a href="https://cubscoutpack152.org/entocort-ec/">entocort ec prices</a> <a href="https://andrealangforddesigns.com/propecia/">propecia</a> self-management, skilled detecting https://mrcpromotions.com/stromectol/ https://ifcuriousthenlearn.com/furosemide/ https://shilpaotc.com/procyclidine/ https://damcf.org/buy-lasix-online/ https://charlotteelliottinc.com/product/imitrex/ https://cubscoutpack152.org/vinpocetine/ https://shilpaotc.com/lomexin/ https://andrealangforddesigns.com/drugs/uloric/ https://endmedicaldebt.com/drugs/epsolay/ https://rrhail.org/pill/hydroquinone-topical/ https://sci-ed.org/nitrofurantoin-online/ https://breathejphotography.com/hygroton/ hygroton https://downtowndrugofhillsboro.com/drug/yasmin/ https://breathejphotography.com/cyclogyl/ https://inthefieldblog.com/isofair/ https://charlotteelliottinc.com/item/hydroxychloroquine-online-no-script/ https://racelineonline.com/methylprednisolone/ https://tonysflowerstucson.com/vidalista/ https://cubscoutpack152.org/entocort-ec/ https://andrealangforddesigns.com/propecia/ secreting asymmetrical damage, fat.