Author Topic: Capital letters and underscores  (Read 4002 times)

0 Members and 1 Guest are viewing this topic.

Offline CrisisTopic starter

  • Global Moderator
  • *
  • *
  • Posts: 3016
  • Activity:
    3.6%
  • Reputation Power: 41
  • Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.Crisis is a force to reckon with.
  • Gender: Male
  • Scripting well enough to break things!
  • Respect: +206
  • Referrals: 2
    • View Profile
Capital letters and underscores
« on: April 11, 2015, 12:29:15 PM »
0
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?

Offline Endless Night

  • Global Moderator
  • *
  • *
  • Posts: 5467
  • Activity:
    0%
  • Reputation Power: 62
  • Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!Endless Night is awe-inspiring!
  • Respect: +393
  • Referrals: 1
    • View Profile
Re: Capital letters and underscores
« Reply #1 on: April 11, 2015, 05:11:30 PM »
0
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

« Last Edit: April 11, 2015, 05:14:45 PM by Endless Night »
Outlaw Josey Wales - "Manwink, A Long Gone Scripty, and Endless are always teasing us with their private sections lol. What there realy saying is scripters rule and users drool."
Briza - "Your a living breathing vortex of usefulness."

Offline Zurg

  • Full Member
  • ***
  • Posts: 105
  • Activity:
    0%
  • Reputation Power: 2
  • Zurg has no influence.
  • Gender: Male
  • Respect: +10
  • Referrals: 0
    • View Profile
Re: Capital letters and underscores
« Reply #2 on: April 12, 2015, 01:38:01 PM »
0
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.
Just glad to have a blast

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Capital letters and underscores
« Reply #3 on: April 13, 2015, 05:15:13 AM »
0
Capitalization definitely does not matter. %MageBook, %MAGEBOOK, %MaGeBoOk, etc are all the same variable.
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline Crome969

  • Elite
  • *
  • *
  • Posts: 2098
  • Activity:
    0%
  • Reputation Power: 25
  • Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.Crome969 is on the verge of being accepted.
  • Gender: Male
  • UO Enthusiast
  • Respect: +211
  • Referrals: 10
    • View Profile
    • ScriptSDK
Re: Capital letters and underscores
« Reply #4 on: April 13, 2015, 07:19:21 AM »
0
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.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Capital letters and underscores
« Reply #5 on: April 13, 2015, 08:01:42 AM »
0
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.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline The Ghost

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Respect: +245
  • Referrals: 0
    • View Profile
Re: Capital letters and underscores
« Reply #6 on: April 13, 2015, 11:08:31 AM »
0
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  :)

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Capital letters and underscores
« Reply #7 on: April 13, 2015, 11:16:55 AM »
0
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!
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline 12TimesOver

  • Another Day, Another Vendetta
  • Global Moderator
  • *
  • *
  • Posts: 3694
  • Activity:
    0%
  • Reputation Power: 41
  • 12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.12TimesOver is a force to reckon with.
  • Gender: Male
  • Respect: +321
  • Referrals: 2
    • View Profile
Re: Capital letters and underscores
« Reply #8 on: April 13, 2015, 12:22:36 PM »
0
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
When they come for me I'll be sitting at my desk
     with a gun in my hand wearing a bulletproof vest
My, my, my how the time does fly
     when you know you're gonna die by the end of the night

Offline The Ghost

  • Elite
  • *
  • *
  • Posts: 1917
  • Activity:
    0%
  • Reputation Power: 25
  • The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.The Ghost is on the verge of being accepted.
  • Respect: +245
  • Referrals: 0
    • View Profile
Re: Capital letters and underscores
« Reply #9 on: April 13, 2015, 04:23:30 PM »
0
Call it OCD but I use most of the time first letter capital   Gosub DropItem,   MoveItems   sen to be easier to read.

Offline Zurg

  • Full Member
  • ***
  • Posts: 105
  • Activity:
    0%
  • Reputation Power: 2
  • Zurg has no influence.
  • Gender: Male
  • Respect: +10
  • Referrals: 0
    • View Profile
Re: Capital letters and underscores
« Reply #10 on: April 13, 2015, 05:44:27 PM »
0
Nice to see everyone pick at each other and have a great time what makes the days go by good.
Just glad to have a blast

Offline declo

  • Jr. Member
  • **
  • Posts: 90
  • Activity:
    0%
  • Reputation Power: 2
  • declo has no influence.
  • Respect: +16
  • Referrals: 1
    • View Profile
Re: Capital letters and underscores
« Reply #11 on: June 01, 2015, 12:59:40 PM »
0
...guess I am the twisted one...

set %bANKbAG SHEEZZ

Tags: