C++: AHK source code: demo A_ variables

Talk about things C/C++, some related to AutoHotkey
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

C++: AHK source code: demo A_ variables

25 Aug 2018, 22:33

- Here are some demo AHK A_ variables written in C++.
- They are intended for teaching purposes.
- Once inserted into the source code, and compiled, they work just like any other built-in variables.
- I would welcome people to post better more efficient versions of the variables. (Or perhaps other examples.)

- A_ variables can be added to AutoHotkey by changing 3 files:
- Trivial additions are made to script.h and script.cpp.
- The function proper is added to script2.cpp.
- (These are the same 3 files required to add built-in functions.)
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: C++: AHK source code: demo A_ variables

25 Aug 2018, 22:36

Code: Select all

==================================================

for AHK v1: A_ variable names:

A_CParen [returns )]
A_EmptyString [an empty built-in variable function that returns a string]
A_OParen [returns (]
A_ReturnString [a built-in variable function that returns 'hello world']
A_SQ [returns ']

==================================================

[script.h]

BIV_DECL_R (BIV_CParen);
BIV_DECL_R (BIV_EmptyString);
BIV_DECL_R (BIV_OParen);
BIV_DECL_R (BIV_ReturnString);
BIV_DECL_R (BIV_SQ);

==================================================

[script.cpp]

	A_(CParen),
	A_(EmptyString),
	A_(OParen),
	A_(ReturnString),
	A_(SQ),

==================================================

[script2.cpp]

VarSizeType BIV_CParen(LPTSTR aBuf, LPTSTR aVarName)
{
	if (aBuf)
	{
		*aBuf++ = ')';
		*aBuf = '\0';
	}
	return 1;
}

VarSizeType BIV_EmptyString(LPTSTR aBuf, LPTSTR aVarName)
{
	//returns whatever the last string was
	return 1;
}

VarSizeType BIV_OParen(LPTSTR aBuf, LPTSTR aVarName)
{
	if (aBuf)
	{
		*aBuf++ = '(';
		*aBuf = '\0';
	}
	return 1;
}

VarSizeType BIV_ReturnString(LPTSTR aBuf, LPTSTR aVarName)
{
	if (aBuf)
		_tcscpy(aBuf, _T("hello world"));
	//return (VarSizeType)_tcslen(_T("hello world"));
	return 11;
}

VarSizeType BIV_SQ(LPTSTR aBuf, LPTSTR aVarName)
{
	if (aBuf)
	{
		*aBuf++ = '\'';
		*aBuf = '\0';
	}
	return 1;
}

==================================================
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “C/C++”

Who is online

Users browsing this forum: No registered users and 6 guests