ScriptUO

Official ScriptUO EasyUO Scripts => Scripting Chat => Topic started by: Crisis on April 11, 2015, 12:29:15 PM

Title: Capital letters and underscores
Post by: Crisis on April 11, 2015, 12:29:15 PM
I have some questions about this to make sure that I am solid in any future scripting attempts:

1. Capital letters vs lower case: Can I set something with caps set %Secure and then call it with %secure? Does it work the same with menus?

2. Underscores: Is there any benefit to separating words with underscores vs putting the two words together? %mage_book vs magebook

3. If these capital and lower case letters are interchangeable and words using underscores or combined don't really matter, does it make a script flow smoother or look neater by doing one vs another?
Title: Re: Capital letters and underscores
Post by: Endless Night on April 11, 2015, 05:11:30 PM
doesn't matter ... all personal choice.

People do it certain ways as they think it makes it easier to read or just thats how they like it

MageBook
magebook
mage_book
mAGEbOOK

etc

I tend to do  MageBook_1
                  MageBook_2

Pick your poison....  ;D


As to whether    %Magebook   and %mAGEbook   are the same variable I've forgotten   %mage_book is defainatly not the same as %magebook

try this to get answer

Code: [Select]
set %magebook YES-same
display ok are they the same ?  %MAGEBook  
halt

Title: Re: Capital letters and underscores
Post by: Zurg on April 12, 2015, 01:38:01 PM
Very good question Crisis. I'm sure they are getting tried of my 1 billion newbie questions. I was wandering the same thing.
And Thanks for the answer EN.
Title: Re: Capital letters and underscores
Post by: 12TimesOver on April 13, 2015, 05:15:13 AM
Capitalization definitely does not matter. %MageBook, %MAGEBOOK, %MaGeBoOk, etc are all the same variable.
Title: Re: Capital letters and underscores
Post by: Crome969 on April 13, 2015, 07:19:21 AM
Even if it doesnt matter its an unwritten rule to format variables by the same kind. Back then on euo i prefered lowercase combined with _

like %ocr_code_for_lethal_darths_quest so the naming was good and selfexplaining but i also saw people coding like subs in subs to obfuscate functions like

sub blabla
 gosub %1 %2 %3 %4

It depends on your style and target of consumers. If you just want good code clearly readable and understandable a stil together with some patterns are always good. If you want to make it impossible to read name your vars like %jch443hcd439nuc and make anonymous sub calls.
Title: Re: Capital letters and underscores
Post by: TrailMyx on April 13, 2015, 08:01:42 AM
I wish I would have adopted a convention and stuck with it.  Sometimes my code uses the underscore, sometimes I capitalize.  The curse of a lazy programmer I suppose.  :)  Whatever makes your code more readable for you.
Title: Re: Capital letters and underscores
Post by: The Ghost on April 13, 2015, 11:08:31 AM
I wish I would have adopted a convention and stuck with it.  Sometimes my code uses the underscore, sometimes I capitalize.  The curse of a lazy programmer I suppose.  :)  Whatever makes your code more readable for you.

So lot of us will be like you.  since you had been teaching to most of us  :)
Title: Re: Capital letters and underscores
Post by: TrailMyx on April 13, 2015, 11:16:55 AM
So lot of us will be like you.  since you had been teaching to most of us  :)

I hadn't thought about that.  I apologize in advance for my schizophrenic code and its affect on the masses!
Title: Re: Capital letters and underscores
Post by: 12TimesOver on April 13, 2015, 12:22:36 PM
So lot of us will be like you.  since you had been teaching to most of us  :)

I hadn't thought about that.  I apologize in advance for my schizophrenic code and its affect on the masses!
Haha, I'm guilty of learning some of your bad habits then considering my first, mostly personal, works were slightly modified TM plagiarisms while I learned the ropes. I think I'm now down to my Gumpwait sub still holding on to your design of passing two Gump name options instead of just one (although I never use the second) simply because I had no idea WTF I was doing and thought it was a requirement lol. Happily, everything else is guilt-free! :D hehe. Boy that was a long time ago... *insert nostalgic sigh here*

On the topic of caps, I'm typically a %MyVarsAreLikeThis kind of guy - I've even gone back and cleaned up scripts to fix this very thing, not that they are all addressed now. I like things to be readable and I HATE having to use a Shift+_ combination every time I type out a variable - ewww!!!!

X
Title: Re: Capital letters and underscores
Post by: The Ghost on April 13, 2015, 04:23:30 PM
Call it OCD but I use most of the time first letter capital   Gosub DropItem,   MoveItems   sen to be easier to read.
Title: Re: Capital letters and underscores
Post by: Zurg on April 13, 2015, 05:44:27 PM
Nice to see everyone pick at each other and have a great time what makes the days go by good.
Title: Re: Capital letters and underscores
Post by: declo on June 01, 2015, 12:59:40 PM
...guess I am the twisted one...

set %bANKbAG SHEEZZ