Author Topic: Sharing Global Variables with a DLL  (Read 1095 times)

0 Members and 1 Guest are viewing this topic.

Charles Pegge

  • Guest
Sharing Global Variables with a DLL
« on: September 16, 2019, 06:20:08 AM »
This feature was developed to aid the splitting of large programs into DLLs. It allows a group of global variables to be easily shared without renaming or major alterations to the original program.

Original Program:
Code: [Select]
int a=1
int b=2
int c=3
float f=1.5
string s="hello"
string cr=chr(13,10)
print a cr b cr c cr f cr s cr

split:
DLL:
Code: [Select]
$filename "o.dll"
$dll
uses rtl32
'sharable globals
int a=1
int b=2
int c=3
float f=1.5
string s="hello"

function shareGlobals() as sys export
=====================================
return @a
end function

Main Program:
Code: [Select]
extern lib "o.dll"
! shareGlobals
end extern
sys sg=shareGlobals()
bind sg {
 int a
 int b
 int c
 float f
 string s
}
string cr=chr(13,10)
print a cr b cr c cr f cr s cr
« Last Edit: September 17, 2019, 08:10:54 AM by Charles Pegge »

Brian Alvarez

  • Guest
Re: Sharing Global Variables with a DLL
« Reply #1 on: September 17, 2019, 11:49:39 AM »
Im sure im going to find a use for this feature, thanks Charles! :)