PDA

View Full Version : are Constants as Optional Default-Parameters invalid?



ReneMiner
18-05-2013, 18:18
What is wrong in my Functions-Name/Parameters ?

I tried with "optional" before all lines - same result - missing close parens:



Uses "CONSOLE"
' I just left those constants inside...

Begin Const

%NODE_PREVIOUS = -3
%NODE_NEXT
%NODE_UBOUND
%NODE_NONE
%NODE_FIRST

%NODE_Parent
%NODE_Sibling
'%NODE_Child

'[] flags


%NODE_DELETED = &H00000000
%NODE_COLLAPSED = &H00000001
%NODE_EXPANDED = &H00000002

End Const
$NODE_DELETED = MKL$(%NODE_DELETED)



WaitKey

Function NODE_Add( Optional sUser As String = "", _
lUser As Long = 0, _
Relative As Long = %NODE_NONE, _
Relation As Long = %NODE_PARENT, _
Flags As Long = %NODE_COLLAPSED, _
Position As Long = %NODE_UBOUND _
) As Long


End Function


for sUser and lUser I don't need default-values but why doesn't this accept the constants as defaults? I use constant values as %MB_OK in some Gadget-Sub, there it works.

ErosOlmi
18-05-2013, 20:20
Hi Rene,

there are 2 problems:

default values for string parameters is not supported
at the time script Function syntax is parsed (pre-parsing stage), script equates are not loaded so your constants are not known by the parser


This will work:

Function NODE_Add( Optional sUser As String , _ lUser As Long = 0 , _
Relative As Long = 0, _
Relation As Long = 1, _
Flags As Long = &H00000001, _
Position As Long = -1 _
) As Long


End Function


I'm sorry but so far this is the situation.
Eros

ReneMiner
18-05-2013, 20:24
OK, the first string and long don't need defaults anyway (sUser and lUser)... thanx- my brain seems to be glued with something somehow :D

Propbably because my neighbours listen to grind-core on full volume the whole day