Sub (Member)

Declares or defines a member procedure

Syntax
	{ KeyPgTypeType | KeyPgClassClass | KeyPgUnionUnion } typename
		KeyPgDeclareDeclare [ KeyPgStaticMemberStatic | KeyPgConstMemberConst ] Sub fieldname [calling convention 
		specifier] [ KeyPgAliasAlias external_name ] ( [ parameters ] ) [ KeyPgStaticStatic ] 
	End { KeyPgTypeType | KeyPgClassClass | KeyPgUnionUnion }

	Sub typename.fieldname ( [ parameters ] ) [ KeyPgExportExport ]
		statements
	End Sub

Parameters
	typename 
		name of the KeyPgTypeType, KeyPgClassClass, or KeyPgUnionUnion
	fieldname 
		name of the procedure
	external_name
		name of field as seen when externally linked
	parameters 
		the parameters to be passed to the procedure
	calling convention specifier	
		can be one of: KeyPgCdeclcdecl, KeyPgStdcallstdcall or KeyPgPascalpascal

Description
	Sub members are accessed with KeyPgOpMemberAccessOperator . (Member Access) or 
	KeyPgOpPtrMemberAccessOperator -> (Pointer To Member Access) to call a member procedure and 
	may optionally accept parameters either KeyPgByvalByVal or KeyPgByrefByRef.  typename be 
	overloaded  without explicit use of the KeyPgOverloadOverload keyword.

	typename is the name of the type for which the Sub method is declared 
	and defined.  Name resolution for typename follows the same rules as 
	procedures when used in a KeyPgNamespaceNamespace.

	A hidden KeyPgThisThis parameter having the same type as typename is passed to 
	non-static member procedures.  KeyPgThisThis is used to access the fields of the 
	KeyPgTypeType, KeyPgClassClass, or KeyPgUnionUnion.
	To access duplicated symbols defined as global outside the Type, add one 
	or preferably two dot(s) as prefix: .SomeSymbol or preferably ..
	SomeSymbol (or only ..SomeSymbol if inside a KeyPgWithWith..End With block).

	A KeyPgStaticMemberStatic (Member) may be declared using the Static specifier.  A 
	KeyPgConstMemberConst (Member) may be declared using the Const specifier.

Example
	Type Statistics
	  count As Single
	  sum As Single
	  Declare Sub AddValue( ByVal x As Single )
	  Declare Sub ShowResults( )
	End Type

	Sub Statistics.AddValue( ByVal x As Single )
	  count += 1
	  sum += x
	End Sub

	Sub Statistics.ShowResults( )
	  Print "Number of Values = "; count
	  Print "Average          = ";
	  If( count > 0 ) Then
	   Print sum / count
	  Else
	   Print "N/A"
	  End If
	End Sub

	Dim stats As Statistics

	stats.AddValue 17.5
	stats.AddValue 20.1
	stats.AddValue 22.3
	stats.AddValue 16.9

	stats.ShowResults

Output:

	Number of Values =  4
	Average          =  19.2

Dialect Differences
	* Only available in the CompilerOptlang-lang fb dialect.

See also
	* KeyPgClassClass
	* KeyPgMemberFunctionFunction (Member)
	* KeyPgSubSub
	* KeyPgTypeType

