Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » ESC macro problem
ESC macro problem [message #52185] Tue, 06 August 2019 16:16 Go to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
linux, svn 13505

I'm writing a macro and is trying to use either lambda or fn to create callable sub-routines
but find that ESC-functions like GetCursor() and Find() is not available in either.

If I put all the code in the macro itself it works fine, but has a lot of repeating code.

1. What must I do to have access to the ESC-functions within either a lambda or an fn?

2. Also, what is the 'instance' refered to in:
Quote:
. lambda(args) ! instance | Invokes lambda, using instance as instance for lambda execution (accessible via .name or self).


Below demonstrates the issue:
macro "PROBLEM" Ctrl+F8
{
	ClearConsole();
	cp = GetCursor();
	A = "STD";
	B = "COUT";
	
	//this works fine...
	#:cat(a, b, &x) { x = a + ">>>>>" + b; }
	
	c = "error";
	:cat(A, B, c);
	cout(c);
	
	
	//this fails with: [..] 'SetCursor' is not a lambda
	#:test(a, b)
	{
		SetCursor(0);
		if (Find("std::cout", 1, 1))
		{
			f = GetSelBegin();
			l = GetSelCount();
			SetCursor(f);
			Remove(l);
			s = a + "::" + b;
			Insert(s);
		}
	}
	
	:test(A, B);
	SetCursor(cp);
	
}


thx

[Updated on: Tue, 06 August 2019 17:14]

Report message to a moderator

Re: ESC macro problem [message #52191 is a reply to message #52185] Wed, 07 August 2019 14:21 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member

I've updated another question: https://www.ultimatepp.org/forums/index.php?t=msg&th=107 42&start=0&
attaching a macro that clearly shows the duplications of code that should be in callable lambdas of fn's
Re: ESC macro problem [message #52210 is a reply to message #52191] Fri, 09 August 2019 10:03 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Macros are really "methods of editor", and SetCursor etc.. are methods too, that is why you cannot invoke them in global functions. You need to define a method...

	.test = @(a, b)
	{
		SetCursor(0);
		if (Find("STD::COUT", 1, 1))
		{
			f = GetSelBegin();
			l = GetSelCount();
			SetCursor(f);
			Remove(l);
			s = a + "::" + b;
			Insert(s);
		}
	};
	
	test(A, B);
Re: ESC macro problem [message #52220 is a reply to message #52210] Sun, 11 August 2019 13:06 Go to previous messageGo to next message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
thx mirek, that works fine now

2nd question:
Is it possible to override ide menu-items and toolbar-buttons from macro's and call their real code
after I've done some 'pre-processing' of my own?
In other words I want to intercept the user-action and do something and then let the original method continue.

Re: ESC macro problem [message #52230 is a reply to message #52220] Mon, 12 August 2019 17:07 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
slashupp wrote on Sun, 11 August 2019 13:06
thx mirek, that works fine now

2nd question:
Is it possible to override ide menu-items and toolbar-buttons from macro's and call their real code
after I've done some 'pre-processing' of my own?


No.
Re: ESC macro problem [message #52237 is a reply to message #52230] Tue, 13 August 2019 10:40 Go to previous message
slashupp is currently offline  slashupp
Messages: 231
Registered: July 2009
Experienced Member
oops! you misspelled "Not yet" Smile
Previous Topic: thread bug....and fix
Next Topic: SOLVED: icon no longer shows
Goto Forum:
  


Current Time: Thu Mar 28 23:12:17 CET 2024

Total time taken to generate the page: 0.02196 seconds