Please enable JavaScript to view this site.

thinBasic Help Manual

* * HELP & MANUAL PREMIUM PACK 4 DEMO VERSION * *

This documentation was styled with a demo skin from the Premium Pack 4 add-on for Help & Manual. The contents of the skin are encrypted and not configurable. You can only publish HM projects with this skin. You cannot edit it or change it.

This version is copyright and may only be used for local testing purposes. It may not be distributed.

Please purchase the full version of the Premium Pack to get the configurable skins and remove this notice. The package will also include the Toolbox configuration utility for Premium Pack skins.

 

Description

 

Set function or sub address to a previously general declared function or sub.

 

Syntax

 

DECLARE SET { ADDRESS | AT } GeneralFunctionName, ProcAddress

 

Returns

 

None

 

Parameters

 

Name

Type

Optional

Meaning

GeneralFunctionName

An unique name

No

Name of a previously declared general function or sub.

ProcAddress

Numeric

No

Process address to be assigned to general declared function or sub.

 

Remarks

 

Syntax can be either:

DECLARE SET ADDRESS ...

or

DECLARE SET AT ...

 

Restrictions

 

See also

 

DECLARE (General form)

 

Examples

 

'---

'---Standard API functions to get a function address. Those functions are used to simulate Petr SomeDirtyAPIToTellMeHandle function

'---

Declare Function LoadLibrary    Lib "KERNEL32.DLL" Alias "LoadLibraryA"   (lpLibFileName As ASCIIZAs Long

Declare Function GetProcAddress Lib "KERNEL32.DLL" Alias "GetProcAddress" (ByVal hModule As DWORD, lpProcName As ASCIIZAs Long

 

 

'---Commented line is a standard API declare for IsCharUpper function. We will not use this way in this example but ... (see next comment)

'DECLARE FUNCTION IsCharUpper LIB 'USER32.DLL' ALIAS 'IsCharUpperA' (BYVAL cChar AS BYTE) AS LONG

 

'--- ...we will tell thinBasic you are defining a generic function not jet initialized (ie, library and address are missing)

Declare Function IsCharUpper (ByVal cChar As ByteAs Long

 

 

'---OK, here we start simulating the assigment of the procedure address

Dim hLib As Long

Dim hProc As Long

 

'---First we need to load the library from where we want the address of the function

hLib = LoadLibrary("USER32.DLL")

'---If return value is NOT zero all is ok

If hLib <> 0 Then

  '---Now we try to get the address of the prodecure inside the library

  hProc = GetProcAddress(hLib, "IsCharUpperA")

  '---If return value is NOT zero all is ok

  If hProc <> 0 Then

 

    '---

    '---Here the new thinBasic functionality. It assign a process address to a generic previously declared function allowing subsequent calling

    Declare Set ADDRESS IsCharUpper, hProc

    '---So we are telling thinBasic that the previous declared function 'IsCharUpper' has now its process address

 

    '---Now we try to use the new functionality that will tell us if a char is upper or not

    Dim Char As String VALUE "F"

    Dim AsciiChar As Byte VALUE ASC(Char)

    MSGBOX 0, "OK. IsCharUpper for char " & Char & " returned: " & IsCharUpper(AsciiChar) & " (1=true and 0= false)"

  Else

    MSGBOX 0, "It was not possible to get the procedure address"

  End If

Else

  MSGBOX 0, "It was not possible to load library"

End If  

Created with Help+Manual 8 and styled with Premium Pack Version 4 © by EC Software