You are not logged in.

#1 27 Dec 2012 14:09

Ed Dyreen
Member
From: Flanders_( Belgium )
Registered: 29 Feb 2008
Posts: 18
Website

Global, local naming scheme

'
So there are 3 different ways of saying almost exactly the same thing

Set object 	= Nothing
variable 	= Null
variable 	= Empty

Not exactly the same, but they should be !

Then there is another problem that when you declare a global variable and redeclare it locally WSH will complain the variable is already used globally. But it shouldn't, a global variable that is redeclared locally should be local making the global variable inaccessible.
I noticed some always append local variables with "my"... That may be not a bad idea...

Dim variable : variable = something
Function myFunc( myVariable )
	'My code here
End Function

Now I need to think out a good naming scheme to overcome these bad programming styles promoted by MS. And it gets worse, you can't declare the type of variable beforehand so you'll easily loose track of what kind of variable you're actually working with. Is it an array or a collection ?

' Abbrevations for VBScript 	: long 		: short
'
' myObject global scope 	: glbMyObject	:  MyObject
' myObject local scope 		: locMyObject	: lMyObject
'
' myObject STRING 		: strMyObject	: sMyObject
' myObject INTEGER 		: intMyObject	: iMyObject
' myObject BOOLEAN 		: blnMyObject	: bMyObject
' myObject ARRAY 		: arrMyObject	: aMyObject
' myObject COLLECTION 		: colMyObject	: cMyObject
' myObject OBJECT 		: objMyObject	: oMyObject
' myObject CLASS 		: clsMyObject	:  MyObject
 

I haven't listed all types as I haven't used them yet... But so far, What you guys think of this ?

Last edited by Ed Dyreen (27 Dec 2012 15:16)

Offline

#2 18 Jul 2013 13:18

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: Global, local naming scheme

Heres a function IsBlank() for dealing with null/empty variables
http://ss64.com/vb/syntax-null.html

Some naming suggestions here:
http://ss64.com/vb/syntax-naming.html

An argument could be made for using the b prefix for Byte and f (flag) for boolean

Offline

#3 05 Sep 2013 14:33

Rnoldz
New Member
Registered: 05 Sep 2013
Posts: 1

Re: Global, local naming scheme

Why does the IsBlank() function at ss64.com/vb/syntax-null.html have all of the Exit Functions?  They are not needed with they way the function is written.

Offline

#4 06 Sep 2013 20:51

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: Global, local naming scheme

^ Good point, I've stripped them out now.

Offline

Board footer

Powered by