WinBatch Technical Support Forum
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Current version: 2022C (6.22CVC)
Home
Help
Search
Tech Database
Documentation
Downloads
Hints
Login
Register
WinBatch Technical Support Forum
»
All Things WinBatch
»
WinBatch
»
Global Variables
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: Global Variables (Read 395 times)
mueer01
Newbie
Posts: 21
Global Variables
«
on:
January 17, 2022, 07:42:39 am »
Hello,
is it possible to define GLOBAL variables?
Example:
---
#DefineFunction TestFunction()
Message( "Global", GlobalVariable )
#EndFunction
GlobalVariable = "Hello"
TestFunction( )
---
Logged
td
Tech Support
Posts: 4044
Re: Global Variables
«
Reply #1 on:
January 17, 2022, 08:01:56 am »
Please see the
PtrGLobalDefine
function in the Consolidated WIL Help file or online here:
https://docs.winbatch.com/mergedProjects/WindowsInterfaceLanguage/html/WILLZ_P__015.htm
Logged
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
- Dr. Tom Cade
mueer01
Newbie
Posts: 21
Re: Global Variables
«
Reply #2 on:
January 18, 2022, 01:24:40 am »
Many Thanks
Logged
kdmoyers
Sr. Member
Posts: 452
Re: Global Variables
«
Reply #3 on:
January 18, 2022, 07:49:50 am »
Here's another example
Code: Winbatch
fred
=
6
ptrglobaldefine
(
fred
)
; make that variable "global"
#definefunction
abc
(
x
)
fred
=
ptrglobal
(
fred
)
; grab the pointer
*
fred
+=
1
; add one to the value
return
x
+
*
fred
; use the value to compute something
#endfunction
message
(
''
, abc
(
100
)
)
; shows 107
message
(
''
, abc
(
100
)
)
; shows 108
exit
Logged
The mind is everything; What you think, you become.
td
Tech Support
Posts: 4044
Re: Global Variables
«
Reply #4 on:
January 18, 2022, 01:49:56 pm »
How about declaring today obfuscation Tuesday?
Code: Winbatch
x
=
42
PtrGlobalDefine
(
x
)
PtrGlobalDefine
(
pX
)
ppX
=
PtrGlobal
(
px
)
*
ppX
=
PtrGlobal
(
x
)
#DefineFunction
Useless
(
)
g_ppX
=
PtrGlobal
(
pX
)
g_px
=
*
g_ppX
return
*
g_px
#EndFunction
z
=
Useless
(
)
Message
(
'True?'
, z
:
' == '
:
x
)
exit
Logged
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
- Dr. Tom Cade
kdmoyers
Sr. Member
Posts: 452
Re: Global Variables
«
Reply #5 on:
January 18, 2022, 03:24:50 pm »
whoa, that's good! I'm going to have to stare at that a bit...
Logged
The mind is everything; What you think, you become.
Print
Pages: [
1
]
Go Up
« previous
next »
WinBatch Technical Support Forum
»
All Things WinBatch
»
WinBatch
»
Global Variables