Author Topic: Short alternative to 'declare function'  (Read 3292 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Short alternative to 'declare function'
« 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

Peter

  • Guest
Re: Short alternative to 'declare function'
« Reply #1 on: June 07, 2012, 04:27:18 AM »
Why not ?

kryton9

  • Guest
Re: Short alternative to 'declare function'
« Reply #2 on: June 07, 2012, 11:38:38 AM »
Code: OxygenBasic
  1. declare function AbortDoc lib "gdi32.dll" alias "AbortDoc" (byVal hdc as long) as long
  2. ! AbortDoc lib "gdi32.dll" alias "AbortDoc" (byVal hdc as long) as long
So line 2 would be the same line 1?

Peter

  • Guest
Re: Short alternative to 'declare function'
« Reply #3 on: June 07, 2012, 11:47:34 AM »
Hi Kent,

! AbortDoc lib "gdi32.dll"  (sys hdc) as sys 

kryton9

  • Guest
Re: Short alternative to 'declare function'
« Reply #4 on: June 07, 2012, 12:09:13 PM »
That's nice it is quite a bit shorter and easier to read!

Charles Pegge

  • Guest
Re: Short alternative to 'declare function'
« Reply #5 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
« Last Edit: June 07, 2012, 02:19:28 PM by Charles Pegge »

kryton9

  • Guest
Re: Short alternative to 'declare function'
« Reply #6 on: June 07, 2012, 02:17:10 PM »
This is fantastic stuff.