C++: AHK source code: demo A_ variables

Post a reply


In an effort to prevent automatic submissions, we require that you complete the following challenge.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :| :mrgreen: :geek: :ugeek: :arrow: :angel: :clap: :crazy: :eh: :lolno: :problem: :shh: :shifty: :sick: :silent: :think: :thumbup: :thumbdown: :salute: :wave: :wtf: :yawn: :facepalm: :bravo: :dance: :beard: :morebeard: :xmas: :HeHe: :trollface: :cookie: :rainbow: :monkeysee: :monkeysay: :happybday: :headwall: :offtopic: :superhappy: :terms: :beer:
View more smilies

BBCode is ON
[img] is OFF
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: C++: AHK source code: demo A_ variables

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

Post by jeeswg » 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;
}

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

C++: AHK source code: demo A_ variables

Post by jeeswg » 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.)

Top