Programming => Bugs & Feature Requests => Topic started by: Charles Pegge on June 07, 2012, 03:52:55 AM
Title: Short alternative to 'declare function'
Post by: Charles Pegge on June 07, 2012, 03:52:55 AM
I propose the use of '!' as a short alternative to 'declare'
thus:
declare fun(sys a,b,c,d) as sys
! fun(sys a,b,c,d) as sys
This would work for both subs and functions.
It is consistent with the use of '%' and '$' for equates.
Charles
Title: Re: Short alternative to 'declare function'
Post by: Peter on June 07, 2012, 04:27:18 AM
Why not ?
Title: Re: Short alternative to 'declare function'
Post by: kryton9 on June 07, 2012, 11:38:38 AM
Code: OxygenBasic
declarefunction AbortDoc lib "gdi32.dll" alias "AbortDoc" (byVal hdc aslong) aslong
! AbortDoc lib "gdi32.dll" alias "AbortDoc" (byVal hdc aslong) aslong
So line 2 would be the same line 1?
Title: Re: Short alternative to 'declare function'
Post by: Peter on June 07, 2012, 11:47:34 AM
Hi Kent,
! AbortDoc lib "gdi32.dll" (sys hdc) as sys
Title: Re: Short alternative to 'declare function'
Post by: kryton9 on June 07, 2012, 12:09:13 PM
That's nice it is quite a bit shorter and easier to read!
Title: Re: Short alternative to 'declare function'
Post by: Charles Pegge on June 07, 2012, 02:11:14 PM
An example of how much contraction is now possible:
(This example requires the Alias)
Declare Function CreateFont Lib "gdi32.dll" Alias "CreateFontA" (ByVal H As Long, ByVal W As Long, ByVal E As Long, ByVal O As Long, ByVal W As Long, ByVal I As Long, ByVal u As Long, ByVal S As Long, ByVal C As Long, ByVal OP As Long, ByVal CP As Long, ByVal Q As Long, ByVal PAF As Long, ByVal F As String) As sys
--->
! CreateFont Lib "gdi32.dll" Alias "CreateFontA" (long H,W,E,O,W,I,U,S,C,OP,CP,Q,PAF,string F) As sys
And you can also remove the lib descriptor by placing all the declares for one library in a block
extern lib "gdi32.dll" ! CreateFont Alias "CreateFontA" (long H,W,E,O,W,I,U,S,C,OP,CP,Q,PAF,string F) As sys ... end extern
Charles
Title: Re: Short alternative to 'declare function'
Post by: kryton9 on June 07, 2012, 02:17:10 PM