Development :  K-Meleon Forum
K-Meleon development related discussions. 
macrolanguage - love it grinning smiley
Posted by: siria
Date: August 14, 2011 03:37AM

Hey, I'm delighted to realize that "and" and "or" actually work inside if-conditions, never knew that! Thought had tried it in the past, and it didn't work then, but perhaps I had some other mistake in the code. Or perhaps I only tried in caps (AND / OR)??
Anyway, there were always workarounds for "and", by boxing conditions, but workarounds for "or" seemed so difficult. Meanwhile I don't understand at all anymore why I had been so blind *blush*
Little example:

test_or{
$_x=prompt("","number?","1");
if($_x<3 or $_x>6) alert("","x<3 or x>6: YES"); else alert("","x<3 or x>6: NO");
}

Perhaps this thread can be used by macro coders to exchange little tips or updates ;-)

Just recently, while I remember it yet:
"setmenu" works also in-session, not just at browser start, as was written somewhere smiling smiley
The rebuildmenu-command is still a mystery to me, but doesn't seem to be needed anyway, since simply setmenu can be used?

Probably a bug, but can come in handy anyway: cool smiley
Inserting a new popup or inline menu but without giving a name (""), makes that the top entry of the parent menu is deleted! Used by jsnj for his search+ macro smiling smiley

And JamesD figured out that comparing variables takes the type (STRING or INT) from the left side of the "=" ! (defines whether e.g. 10 is smaller or greater than e.g. 3) And a prompt seems to return always a STRING. This can be converted to INT by e.g. adding zero: $_x=$_x+0;

Ah yes, had almost forgotten already:
the new RETURN function for injectJS crops a string after 127 characters sad smiley

Yet another:
Input via prompt is cropped after 254 characters sad smiley Although a pref line can hold far longer strings, well over 1000 at least, probably much more. Funnily, when creating a new pref directly on the page about:config, then the input field accepts longer entries. But of course I have no idea how to call that version.
PS: Does anyone know the name of the context menu on about:config??? Would long since like to add an entry to open some help sites. Works fine via mouse gestures, but guess most other people would prefer a menu ;-)



Edited 8 time(s). Last edit at 08/14/2011 04:23AM by siria.

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley
Posted by: JamesD
Date: August 14, 2011 08:37AM

Really good find about the 'or' and 'and' words working with the if statement. They do not work with the older conditional statement.
They seem to work for the while statement. If I get time tomorrow, I guess I had better do some update to MacroLanguage2. I need to put all of your points in the wiki page so user will not need to search so much for them.

I also need to remember how to change the KM language file for Notepad++. The 'or' and 'and' do not show in keyword color.

_Snippet_RunCode {
$_y = 0 ;
$_x=prompt("","number?","1");
if($_x<3 or $_x>6) alert("","x<3 or x>6: YES"); else alert("","x<3 or x>6: NO");

# Does not work with older conditional statement
#$_x<3 or $_x>6 ? alert("","x<3 or x>6: YES") : alert("","x<3 or x>6: NO");  

if ($_x <= 6 and $_x < 3) alert("Both"); else alert("One or neither") ;

while ($_y < 3 and $_x > 2) {
	alert($_y ."  and  ". $_x, "The values are") ;
	$_y = $_y +1;  $_x = $_x -1;
	}
}

As for rebuildmenu, Groups2 and QuickStore both use it. It is when the macro uses code/data to change the menu. see: http://dl.dropbox.com/u/1522294/QuickStore.7z

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley
Posted by: JamesD
Date: August 14, 2011 11:43PM

I have made some changes to prompt() and injectJS() in MacroLanguage2. http://kmeleon.sourceforge.net/wiki/MacroLanguage2

I have started some changes for the Expressions section of MacroLanguage2.
Those changes are in the sandbox. http://kmeleon.sourceforge.net/wiki/SandBox

I really would like some input on the expressions changes. I did not like the old comparison stuff as integer. It really is Boolean. I put an item about the left side controlling at the bottom.

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley
Posted by: JamesD
Date: August 18, 2011 03:44AM

Changes to expressions, while(), and if() have been completed for MacroLanguage2

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley
Posted by: JamesD
Date: August 18, 2011 03:55AM

Quote
siria
Just recently, while I remember it yet:
"setmenu" works also in-session, not just at browser start, as was written somewhere smiling smiley
The rebuildmenu-command is still a mystery to me, but doesn't seem to be needed anyway, since simply setmenu can be used?

I do not know about KM 1.5.4 but in 1.6.0 rebuildmenu is not required. I commented out the rebuildmenu line in Page Load Sound http://kmeleon.sourceforge.net/wiki/KmmPgLdSound and it still worked and changed the menu as designed.

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley
Posted by: adodupan
Date: August 23, 2011 11:48PM

Maybe you can look here and try some of the functions, i assume that MacroLanguage2 should be another update.

Regards.

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley
Posted by: siria
Date: August 24, 2011 01:47AM

Yep smiling smiley Actually I checked it out just recently, when I stumbled in a neighbor file about "reserved words" (or such) "and" and "or" grinning smiley Have no clue about real programming, being only a little KM user dabbling with macrolanguage, so can only pick up little hints here and there from those cvs files, but sometimes they contain interesting descriptions - like in this case. But it seems those functions are pretty much all described in the wiki already or on kko's website.

Don't know how macrolanguage2 page started out, perhaps it was meant as an update, or perhaps meant to be an independent version, that was before my time. But it's always been the "current" version for me, have put the link in all my own macros.

James, I worked with in-session setmenu functions long before 1.6 came about, it worked just the same in KM1.5x already smiling smiley

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley
Posted by: JamesD
Date: August 26, 2011 02:36AM

Quote
siria
Don't know how macrolanguage2 page started out, perhaps it was meant as an update, or perhaps meant to be an independent version, that was before my time. But it's always been the "current" version for me, have put the link in all my own macros.

I began the MacroLanguage2 page. Some new items were being added to the macro language and the organization of the original page was such that I could not decide where in the page to add them. I just tried to lay out a better 'Contents' block and move all the items to fit the new contents block.

I don't know where the first small contents block comes from. It is not part of my work.

I have tried to keep the page updated. I hope that I have been successful. I hope users will always keep me informed if new items become available or any documentation is incorrect. They can, if they wish, update the page themselves. I only ask they follow the existing format where possible.

Quote
siria
James, I worked with in-session setmenu functions long before 1.6 came about, it worked just the same in KM1.5x already smiling smiley

Should I put some information about 'rebuildmenu' being depreciated in modern versions of KM?



Edited 1 time(s). Last edit at 08/26/2011 02:39AM by JamesD.

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley (Link Text)
Posted by: siria
Date: March 04, 2014 11:19PM

Don't know where to put it, but *finally* figured out a way to get the Link Text in a variable.
Handy e.g. for favorites macros, as title for adding link targets. Perhaps for other stuff too.
It's now mainly pieced together from default macros in main.kmm, with some little modifications.
(Wishlist: Would be much easier to have $LinkText as another default variable some day smiling smiley)

If anyone has use, the snippet goes like this:
Quote

$JS_doit="for(var j=0,a=getElementsByTagName('a');j<a.length;j++)with(a[j])if(urlencode(href)=='".urlencode($LinkURL)."'){var linktext=text;} return linktext;";
$_LinkText=injectJS("(function(){".$_JS_urlencode."with(document){".$JS_doit."}})()",frame);
$JS_doit="";

The catch is, injectJS is buggy yet in KM1.7, and because a JS variable needs to be returned the open-workaround doesn't help.
But works fine in KM1.6, and hopefully injectJS gets fixed some day in newer versions.

Perhaps a javascript expert can have a look, am not quite sure about the syntax around "return". Only know it works and error console doesn't complain.



Edited 1 time(s). Last edit at 03/04/2014 11:22PM by siria.

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley (Link Text)
Posted by: rodocop
Date: March 05, 2014 03:06AM

siria,
injectJS bug was fixed (or cured ;-) in 1.7 by Realgy


Try K-Meleon-1.6db+NS by dugbug // KM-16-S2014 by Fred // 1.6beta2.6 by JamesD

K-Meleon Twin+ Download for modern browsers =//= Download for old ones =//= Discuss it!!!

New KM74.0 for test and feedback! Get it there!


Options: ReplyQuote
Re: macrolanguage - love it grinning smiley (Link Text)
Posted by: siria
Date: March 05, 2014 04:29AM

Yes I've seen that a while ago. He has replaced "injectJS" with the "open" workaround, but only now -thanks to you- I've taken a closer look again and am slightly shocked: His fix toggles Javascript and other settings permanently "ON" when reloading images, all secretly without warning the user!

Anyway, the workaround works for most things, but alas not for the one thing that so far only the real injectJS can do: Transfer a javascript-variable to a macro-variable. That's the prob here...

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley (Link Text)
Posted by: siria
Date: March 23, 2014 09:37PM

Just had the prob to get a &-sign into a prompt box.
It was always shown as an underlined blank, and \& didn't help either.
Finally the solution was to type && :-)

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley (Link Text)
Posted by: siria
Date: March 25, 2014 05:32AM

A little bug, just to note it somewhere:
$ARG must not contain commas, or it gets cropped there.
A workaround is to first replace it with a hopefully rather rare sign like ` and later replace it back. (KM1.6)

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley
Posted by: siria
Date: September 19, 2014 04:56PM

Question about macro bug in KM1.6/1.7:
Since 1.6 it's not possible anymore to execute a js-code and in next line toggle off again one of the js-prefs (e.g. capability). Because JS is already off again before the script execution has even started, the toggle-line is executed BEFORE its previous line with the code-injecting! So far I don't know any other workaround but to insert an annoying alert-box before the togglepref just to get a break.

Is there any way to toggle a pref with pure JS in a macro? So that it could be appended to the actual js code and hopefully only toggled AFTER that code is finished?



Edited 1 time(s). Last edit at 09/19/2014 04:56PM by siria.

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley
Posted by: siria
Date: October 13, 2014 06:26AM

Stumbled over this ancient macro in the obsolete KM1.0 archiv:

http://kmeleon.sourceforge.net/wiki/Toggling+toolbars

Crazy! It's actually possible to toggle toolbars with a macro by using
id(2000) or id (2001) .... 200x!!
It also makes that the toolband-pref for visibility gets toggled.

The catch is: those numbers are not fix, can be different for every user :-(
Basically the counter matches the order in the Toolbars-menu, counting from the bottom up. The first 3 are probably fix numbers, the next ones are in the same order as written in toolbars.cfg, then the macro-created toolbars (random), and acc. to the old wiki the MenuBar and BookmarksBar are always the last (correct in KM1.6). My own profile creates those:

id(2000) = toggles TABS bar (not in menu KM16)
2001 = URL
2002 = Throbber (not in menu KM16)
2003 = Main Bar
2004 = Config
2005 = Tab/Win
2006 = Zoom
....
2023 = Menu bar (not in menu KM16)
2024 = bookmarks (in menu line 22, due to KM1.6 not showing 3 bars)

At the moment no use, but remember was looking for a macro-toggle in the past. Perhaps will need it again some day, so noting it here. But the random numbers are probably unsolvable.

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley
Posted by: guenter
Date: October 14, 2014 04:39AM

Maybe it was usefull if Dorian posted how we can find out the values that are apparently moving with the differnt versions.

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley
Posted by: JamesD
Date: October 14, 2014 06:38AM

I see two possibilities. One is that Dorian picks the numbers and the other is that he has an algorithm. If it is the latter, that is all we need.

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley
Posted by: siria
Date: October 14, 2014 07:32AM

Perhaps as a list of the names in a long variable, but not sure how long that could be (PS: Just recently discovered in main.kmm a prepared macro for list items, looks quite interesting). But no urgent matter.

What I'm thinking more and more often though is that a aphabetically sorted toolbars menu would be handy! With a bunch of user macros that list gets just too long if unsorted.

And would love to have that menu checkmark bug fixed also for macro-created buttons and for macro-fired popup-menus, although it's already a HUGE improvement that toolbars.cfg-buttons can now have correct left-click menus smiling smiley

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley
Posted by: rodocop
Date: October 27, 2014 12:06AM

I think that problem here (also affecting skinning) is that toolbars are not unified in KM - there are no standard for toolbar names, for button distribution between them, for button order in the toolbar bmp-file.

So it would be useful to work out such standards. I'm going to do something like this for my next Twin...


Try K-Meleon-1.6db+NS by dugbug // KM-16-S2014 by Fred // 1.6beta2.6 by JamesD

K-Meleon Twin+ Download for modern browsers =//= Download for old ones =//= Discuss it!!!

New KM74.0 for test and feedback! Get it there!


Options: ReplyQuote
Re: macrolanguage - love it grinning smiley
Posted by: siria
Date: October 27, 2014 01:17AM

The default skins always served as naming examples. I just took the old Klassik and Phoenity as template for classiria and extended it on that base. Guess the new Aura doesn't follow a system anymore, but if it still did, that wouldn't help much either to sort a long toolbar list alphabetically ;-)

Options: ReplyQuote
Re: macrolanguage - love it :D
Posted by: adodupan
Date: November 03, 2014 05:55PM

Quote
siria
And would love to have that menu checkmark bug fixed also for macro-created buttons and for macro-fired popup-menus

This is second place where you comment on 'that bug', i'm not sure i understand it.
Give me your 'problematic' file.

Options: ReplyQuote
Re: TEST rebarmenu-bug
Posted by: siria
Date: November 04, 2014 03:14AM

Have made an own thread now for that rebarmenu thing:

http://kmeleon.sourceforge.net/forum/read.php?3,130665



Edited 5 time(s). Last edit at 11/04/2014 04:14AM by siria.

Options: ReplyQuote
Re: TEST rebarmenu-bug
Posted by: JamesD
Date: November 04, 2014 03:55AM

@ siria

I have never used rebarmenu, but am I right in that you want the image on the button to change when you click it? I don't understand the "checkmarks".

Options: ReplyQuote
Re: macrolanguage - love it grinning smiley
Posted by: siria
Date: November 04, 2014 04:07AM

No, the images are something else entirely. I mean the checkmarks as shown in the Privacy Menu, that I'm also using as example. That let's you see in the menu what is blocked and what not.

Lets better discuss this further in a separate thread, that it doesn't get lost inside this general macrolanguage thread.

http://kmeleon.sourceforge.net/forum/read.php?3,130665



Edited 2 time(s). Last edit at 11/04/2014 04:17AM by siria.

Options: ReplyQuote


K-Meleon forum is powered by Phorum.