AmiBroker 6.25.0 BETA released


#26

For some charts work and for some does not, at least in my computer maybe it has something to do with my formula coding, actually I`m sure it does as the charts with simple code formulas pressing CTRL+R works


#27

in combination with the new buttons the key assignments will not work


#28

Yep that`s it, it does not work on the charts where I have coded Gui buttons.


#29

This may be due to the fact that you have added some GUI controls to your chart code
and those GUI buttons got the input focus and “eat” the keyboard input.

I was already thinking about it because some users wanted keyboard navigation between GUI controls in charts (so you can use arrows to change radio buttons, space to “press” button or change checkboxes, and TAB KEY to navigate between controls) so version 6.25 implements keyboard navigation. The side effect is that if implement keyboard navigation you need keyboard input and certain shortcuts may be affected. I will probably introduce a function that will allow formula writter to control/decide whenever he wants keyboard navigation in GUIcontrols and this should fix the problem.


Short Cut Keys in Debugger
#30

Its ok its not big deal actually I thought its some sort of bug since in prev version worked. Thank you for the info. Gui controls are much more valuable than a shortcuts.


#31

Please don’t throw a “bug” word. If there is an error, I will tell you.
But this is NOT A BUG. It has been implemented for purpose. It is documented feature in the read me for 6.25:

CHANGES FOR VERSION 6.25.0 (as compared to 6.22.0)
[…]
6. AFL: Gui* – keyboard navigation is now enabled (you can tab between controls and use arrows to navigate control groups such as radio boxes)

As I explained in previous post, 6.25 implements KEYBOARD NAVIGATION between GUI (so you can use TAB and arrow keys to NAVIGATE). You can’t have cake and eat cake too. (Other) People asked for keyboard navigation in GUI.

Or better yet, you can call it ‘feature’ of Windows, because it is how WINDOWS IsDialogMessage function works (that is necessary to implement keyboard navigation).
Windows IsDialogMessage eats your messages even if one could think it should not.

As I wrote in previous reply in this thread there will be a function to enable/disable keyboard navigation in GUI controls so both user groups can have what they want.

I think I know why people are so quick to assume bugs in programs. Probably because all other programs including Windows 10 itself are filled with bugs. But that is not the case for AmiBroker, as it is painstakingly crafted the ‘old’ way, when programmers were not only “coders” but had experience starting from digital TTL logic and every bit of memory and every single CPU cycle was precious.

Yesterday I bought Crucial MX300 SSD drive based on good experience with some older models and good reviews only to find out that as soon as you start using it with Windows 10 you get non-stop freezes after about 10 minutes from starting Windows. Also they have software that updates drive’s firmware - written in (sic!) Java and having download size of nearly 300 MB! :frowning_face: Hardware company coding in Java? Is that a joke? What a disaster that is. I could write such program that will be in the size of AmiQuote (that is less than 0.16MB - yes the decimal dot is in right place)
Back in 2000 if you bought harddrive from respectable company like WD, you had 100% guarantee that everything is compatible and works super smoothly everywhere in every OS version. Hardware vendors did not count on “firmware updates” to fix their bugs and testing was done before release. But now? Bugs in hard drives? Bugs in CPUs https://tech.ahrefs.com/skylake-bug-a-detective-story-ab1ad2beddcd


Architecture for taking Amibroker /IB live to large universe of stocks on intraday data?
Is there a way to bypass Keyboard Short Cut Restriction in newer version?
#32

I noticed that when you do a GuiSetCheck for a radio button then it loses its value once you click the chart outside of the radio button area. I am not sure if I use it incorrectly but when I set the GuiCheckBox this is not the case.

i made some example code. When you start the code it should set the first radio button. When you click from 1, to 2 etc it works. However, when you click the chart outside of the radio button area, the trace value returned for all the radio buttons is -1. They lost their value. Am I doing something wrong?

thanks

per1 = Param( "Period 1", 20, 1, 500, 1 );
per2 = Param( "Period 2", 80, 1, 500, 1 );
per3 = Param( "Period 3", 300, 1, 500, 1 );
reset = ParamTrigger( "Reset", "Press Here" );

function calculateSineFunction( per )
{
    ff = sin( 2 * ( 4 * atan( 1 ) ) * Cum( 1 ) / per );
    StaticVarSet( "sinefunc", ff );
}

function getSineFunction()
{
    return StaticVarGet( "sinefunc" );
}


id0 = GuiGetEvent( 0, 0 );
id1 = GuiGetEvent( 0, 1 );

GfxSelectSolidBrush( colorBrightGreen );
x1 = 0;
x2 = 100;
y1 = 30;
y2 = 130;
x3 = 5;
y3 = 5;
GfxRoundRect( x1, y1, x2, y2, x3, y3 );

GuiRadio( "Radio 1", 40, 10, 30, 100, 20, 1 );
GuiRadio( "Radio 2", 41, 10, 50, 100, 20, 1 );
GuiRadio( "Radio 3", 42, 10, 70, 100, 20, 1 );

GuiCheckBox( "Check 1", 50, 10, 110, 100, 20, 1 );

if( Nz( StaticVarGet( "startval" ) ) == 0 OR reset == 1 )
{
    StaticVarSet( "startval", 1 );
    chk = StaticVarGet( "StartCheck" );

    if( chk == 40 )
    {
        GuiSetCheck( 40, 1 );
    }
    else
        if( chk == 41 )
        {
            GuiSetCheck( 41, 1 );
        }
        else
            if( chk == 42 )
            {
                GuiSetCheck( 42, 1 );
            }
            else
            {
                GuiSetCheck( 40, 1 );
            }
}


// radio button toggle
checked = 1;
unchecked = 0;

if( id0 == 40 AND id1 == 1 )
{
    GuiSetCheck( 40, checked );
    GuiSetCheck( 41, unchecked );
    GuiSetCheck( 42, unchecked );
}
if( id0 == 41 AND id1 == 1 )
{
    GuiSetCheck( 40, unchecked );
    GuiSetCheck( 41, checked );
    GuiSetCheck( 42, unchecked );
}
if( id0 == 42 AND id1 == 1 )
{
    GuiSetCheck( 40, unchecked );
    GuiSetCheck( 41, unchecked );
    GuiSetCheck( 42, checked );
}

// execute activated radio button at each refresh
if( GuiGetCheck( 40 ) == 1 )
{
    calculateSineFunction( per1 );
    rsine = getSineFunction();
    StaticVarSet( "StartCheck", 40, 1 );
}
if( GuiGetCheck( 41 ) == 1 )
{
    calculateSineFunction( per2 );
    rsine = getSineFunction();
    StaticVarSet( "StartCheck", 41, 1 );
}
if( GuiGetCheck( 42 ) == 1 )
{
    calculateSineFunction( per3 );
    rsine = getSineFunction();
    StaticVarSet( "StartCheck", 42, 1 );
}

_TRACE( "Radio 40, 41, 42: " + GuiGetCheck( 40 ) + ", " + GuiGetCheck( 41 ) + ", " + GuiGetCheck( 42 ) +" Check 50: " + GuiGetCheck( 50 ) );

GraphXSpace = 5;
SetChartBkColor( colorBlack );
Plot( rsine, "", colorBlue, styleLine, Null, Null, 0, 0, 2 );



#33

Oh sorry, I forgot how sensible you are to the word bug it was not intended - nobody but you know the amount of effort you put in to this software which btw is a great piece of software and probably its natural to react when someone throws the word bug mostly because of ignorance, I apologize, minor glitch but I understand now its not even that but a conflict issue. And yes its true that given the complexity of Amibroker its really amazing how it works like a Swiss clock and since up to now I did not encounter anything impossible to achieve with Amibroker (it does not cook though) you must understand that from my part nothing comes as critic, I am one of the most satisfied customers.


#34

“Hello Mr. Ed”, this modification seems to work for me.

Have to go now…

/// @link http://forum.amibroker.com/t/new-radio-buttons/1430
// by empottasch & fxshrat
// version 1.1

Version( 6.25 );

persist = 1;// 0 or1 for persistent vars
per1 = Param( "Period 1", 20, 1, 500, 1 );
per2 = Param( "Period 2", 80, 1, 500, 1 );
per3 = Param( "Period 3", 300, 1, 500, 1 );
reset = ParamTrigger( "Reset", "Press Here" );

function calculateSineFunction( per )
{
    ff = sin( 2 * ( 4 * atan( 1 ) ) * Cum( 1 ) / per );
    StaticVarSet( "sinefunc", ff );
}

function getSineFunction()
{
    return StaticVarGet( "sinefunc" );
}

id0 = GuiGetEvent( 0, 0 );
id1 = GuiGetEvent( 0, 1 );
event = id1 == 1;

GfxSelectSolidBrush( colorBrightGreen );
x1 = 0;
x2 = 100;
y1 = 30;
y2 = 130;
x3 = 5;
y3 = 5;
GfxRoundRect( x1, y1, x2, y2, x3, y3 );

GuiRadio( "Radio 1", 40, 10, 30, 100, 20, 1 );
GuiRadio( "Radio 2", 41, 10, 50, 100, 20, 1 );
GuiRadio( "Radio 3", 42, 10, 70, 100, 20, 1 );

GuiCheckBox( "Check 1", 50, 10, 110, 100, 20, 1 );

if( event ) {
	GuiSetCheck( id0, 1 ); 
	radioON = GuiGetCheck( id0 ) == 1;
}

// radio button toggle
if( id0 == 40 AND event )
{
    StaticVarRemove( "check*" );
    StaticVarSet( "check" + id0, radioON, persist );
}
if( id0 == 41 AND event )
{
    StaticVarRemove( "check*" );
    StaticVarSet( "check" + id0, radioON, persist );
}
if( id0 == 42 AND event )
{
    StaticVarRemove( "check*" );    
    StaticVarSet( "check" + id0, radioON, persist );
}

rsine = Null;

// execute activated radio button at each refresh
if( StaticVarGet( "check40" ) )
{
    calculateSineFunction( per1 );
    rsine = getSineFunction();   
}

if( StaticVarGet( "check41" ) )
{
    calculateSineFunction( per2 );
    rsine = getSineFunction();   
}

if( StaticVarGet( "check42" ) )
{
    calculateSineFunction( per3 );
    rsine = getSineFunction();    
}

_Trace( "Radio 40, 41, 42: " + GuiGetCheck( 40 ) + ", " + GuiGetCheck( 41 ) + ", " + GuiGetCheck( 42 ) +" Check 50: " + GuiGetCheck( 50 ) );

GraphXSpace = 5;
SetChartBkColor( colorBlack );
Plot( rsine, "", colorBlue, styleLine, Null, Null, 0, 0, 2 );

#35

The value of ‘-1’ internally means “no change since last time”. But you should not see that in your formula so this is probably an actual error.

There is a “feature” in Windows that causes that owner draw buttons and checkboxes to not return proper value from GetCheck (it always returns 0). So programs have to workaround that. Due to things like separation of GUI from worker threads (which your AFL executes in ), such workarounds are way more complex than in ‘normal’ (i.e. not multithreaded) programs, and what you see is apparently an error in that workaround and will need to be fixed in next version.


GuiButtons for everyone
#36

Yes that is true but I don’t know why this particular word sounds so bad to me. Maybe because I don’t have exactly friendly relationships with insects of all kinds?


#37

thanks fx & Tomasz. Yes your code works, fx. It makes sense. Only I commented out 2 things, not sure if they are necessary. Not sure if you added that for a reason.

1 thing I could not get to work. When you go out of Amibroker and restart I use this code to set the Check

if( Nz( StaticVarGet( "startval" ) ) == 0 OR reset == 1 )
{
    StaticVarSet( "startval", 1 );
    GuiSetCheck( 40,StaticVarGet( "check40" ) );
	GuiSetCheck( 41,StaticVarGet( "check41" ) );
	GuiSetCheck( 42,StaticVarGet( "check42" ) );
}

it correctly chooses the correct radio button, but I do not see the radio button checked in the chart. Complete code below

/// @link http://forum.amibroker.com/t/new-radio-buttons/1430
// by empottasch & fxshrat
// version 1.1

Version( 6.25 );

persist = 1;// 0 or1 for persistent vars
per1 = Param( "Period 1", 20, 1, 500, 1 );
per2 = Param( "Period 2", 80, 1, 500, 1 );
per3 = Param( "Period 3", 300, 1, 500, 1 );
reset = ParamTrigger( "Reset", "Press Here" );

function calculateSineFunction( per )
{
    ff = sin( 2 * ( 4 * atan( 1 ) ) * Cum( 1 ) / per );
    StaticVarSet( "sinefunc", ff );
}

function getSineFunction()
{
    return StaticVarGet( "sinefunc" );
}

id0 = GuiGetEvent( 0, 0 );
id1 = GuiGetEvent( 0, 1 );
event = id1;// == 1;

GfxSelectSolidBrush( colorBrightGreen );
x1 = 0;
x2 = 100;
y1 = 30;
y2 = 90;
x3 = 5;
y3 = 5;
GfxRoundRect( x1, y1, x2, y2, x3, y3 );

GuiRadio( "Radio 1", 40, 10, 30, 100, 20, 1 );
GuiRadio( "Radio 2", 41, 10, 50, 100, 20, 1 );
GuiRadio( "Radio 3", 42, 10, 70, 100, 20, 1 );

if( event ) 
{
	GuiSetCheck( id0, 1 ); 
	radioON = 1;//GuiGetCheck( id0 ) == 1;
}

if( Nz( StaticVarGet( "startval" ) ) == 0 OR reset == 1 )
{
    StaticVarSet( "startval", 1 );
    GuiSetCheck( 40,StaticVarGet( "check40" ) );
	GuiSetCheck( 41,StaticVarGet( "check41" ) );
	GuiSetCheck( 42,StaticVarGet( "check42" ) );
}

// radio button toggle
if( id0 == 40 AND event )
{
    StaticVarRemove( "check*" );
    StaticVarSet( "check" + id0, radioON, persist );
}
if( id0 == 41 AND event )
{
    StaticVarRemove( "check*" );
    StaticVarSet( "check" + id0, radioON, persist );
}
if( id0 == 42 AND event )
{
    StaticVarRemove( "check*" );    
    StaticVarSet( "check" + id0, radioON, persist );
}

rsine = Null;

// execute activated radio button at each refresh
if( StaticVarGet( "check40" ) )
{
    calculateSineFunction( per1 );
    rsine = getSineFunction();   
}

if( StaticVarGet( "check41" ) )
{
    calculateSineFunction( per2 );
    rsine = getSineFunction();   
}

if( StaticVarGet( "check42" ) )
{
    calculateSineFunction( per3 );
    rsine = getSineFunction();    
}

_Trace( "Radio 40, 41, 42: " + GuiGetCheck( 40 ) + ", " + GuiGetCheck( 41 ) + ", " + GuiGetCheck( 42 ) );// +" Check 50: " + GuiGetCheck( 50 ) );

GraphXSpace = 5;
SetChartBkColor( colorBlack );
Plot( rsine, "", colorBlue, styleLine, Null, Null, 0, 0, 2 );


#38

hehe was drinking some beer and thought that my original version was correct. And now I read again Tomasz’s his response and I think this is also the case although fx found a solution for it that works, using static variables.

That’s where betas are for. In the mean time fx showed the radio buttons can work using static variables. I was just under the impression I made some mistake at first.

while waiting for the next beta version I added a few gadgets to the Radio Button AFL: 1) button pack x0 and y0 coordinates 2) added a phase for the sine functions so you can tune in to your favorite radio station more precisely

/// @link http://forum.amibroker.com/t/new-radio-buttons/1430
// by empottasch & fxshrat
// version 1.1

Version( 6.25 );

persist = 1;// 0 or 1 for persistent vars
per1 = Param( "Period 1", 20, 1, 500, 1 );
per2 = Param( "Period 2", 80, 1, 500, 1 );
per3 = Param( "Period 3", 300, 1, 500, 1 );
phase1 = Param( "Phase 1", 0, 0, 2 * ( 4 * atan( 1 ) ), 0.01 );
phase2 = Param( "Phase 2", 0, 0, 2 * ( 4 * atan( 1 ) ), 0.01 );
phase3 = Param( "Phase 3", 0, 0, 2 * ( 4 * atan( 1 ) ), 0.01 );
x0 = Param( "Buttons Pack x0", 0, 0, 1800, 1 );
y0 = Param( "Buttons Pack y0", 20, 0, 800, 1 );
reset = ParamTrigger( "Reset", "Press Here" );

function calculateSineFunction( per, phase )
{
    ff = sin( 2 * ( 4 * atan( 1 ) ) * Cum( 1 ) / per + phase );
    StaticVarSet( "sinefunc", ff );
}

function getSineFunction()
{
    return StaticVarGet( "sinefunc" );
}

id0 = GuiGetEvent( 0, 0 );
id1 = GuiGetEvent( 0, 1 );
event = id1 == 1;

GfxSelectSolidBrush( colorBrightGreen );
x1 = 0 + x0;
x2 = 80 + x0;
y1 = 0 + y0;
y2 = 59 + y0;
x3 = 5;
y3 = 5;
GfxRoundRect( x1, y1, x2, y2, x3, y3 );

GuiRadio( "Radio 1", 40, 10 + x0, 0 + y0, 100, 20, 1 );
GuiRadio( "Radio 2", 41, 10 + x0, 20 + y0, 100, 20, 1 );
GuiRadio( "Radio 3", 42, 10 + x0, 40 + y0, 100, 20, 1 );

if( event ) 
{
	GuiSetCheck( id0, 1 ); 
	radioON = GuiGetCheck( id0 ) == 1;
	Say("event");
}

if( Nz( StaticVarGet( "startval" ) ) == 0 OR reset == 1 )
{
    StaticVarSet( "startval", 1 );
    GuiSetCheck( 40,StaticVarGet( "check40" ) );
	GuiSetCheck( 41,StaticVarGet( "check41" ) );
	GuiSetCheck( 42,StaticVarGet( "check42" ) );
	Say("starting up");
}

// radio button toggle
if( id0 == 40 AND event )
{
    StaticVarRemove( "check*" );
    StaticVarSet( "check" + id0, radioON, persist );
    Say("Radio 1");
}
if( id0 == 41 AND event )
{
    StaticVarRemove( "check*" );
    StaticVarSet( "check" + id0, radioON, persist );
    Say("Radio 2");
}
if( id0 == 42 AND event )
{
    StaticVarRemove( "check*" );    
    StaticVarSet( "check" + id0, radioON, persist );
    Say("Radio 3");
}

rsine = Null;

// execute activated radio button at each refresh
if( StaticVarGet( "check40" ) )
{
    calculateSineFunction( per1, phase1 );
    rsine = getSineFunction();   
}

if( StaticVarGet( "check41" ) )
{
    calculateSineFunction( per2, phase2 );
    rsine = getSineFunction();   
}

if( StaticVarGet( "check42" ) )
{
    calculateSineFunction( per3, phase3 );
    rsine = getSineFunction();    
}

_Trace( "Radio 40, 41, 42: " + GuiGetCheck( 40 ) + ", " + GuiGetCheck( 41 ) + ", " + GuiGetCheck( 42 ) );// +" Check 50: " + GuiGetCheck( 50 ) );

Plot( rsine, "", colorBlue, styleLine, Null, Null, 0, 0, 2 );


#39

Ed, without beer here ( :slight_smile: )… my original version was just a quick & dirty test one.
Here I have made vrs. 1.2 which is something like 10 lines shorter than my original modification.
Actually GuiSetCheck is not required.
And as for your question I use id1 == 1 because it is clickevent.

/// @link http://forum.amibroker.com/t/amibroker-6-25-0-beta-released/1362/37
// by empottasch & fxshrat
// version 1.2

Version( 6.25 );

persist = 1;// 0 or 1 for persistent vars
per1 = Param( "Period 1", 20, 1, 500, 1 );
per2 = Param( "Period 2", 80, 1, 500, 1 );
per3 = Param( "Period 3", 300, 1, 500, 1 );
//reset = ParamTrigger( "Reset", "Press Here" );

function calculateSineFunction( per ) {
    ff = sin( 2 * ( 4 * atan( 1 ) ) * Cum( 1 ) / per );
    StaticVarSet( "sinefunc", ff );
}

function getSineFunction() {
    return StaticVarGet( "sinefunc" );
}

id0 = GuiGetEvent( 0, 0 );
id1 = GuiGetEvent( 0, 1 );
clickevent = id1 == 1;

x1 = 0; 
y1 = 30;
x2 = 100; 
y2 = 130;
x3 = 5; 
y3 = 5;
GfxSelectSolidBrush( colorBrightGreen );
GfxRoundRect( x1, y1, x2, y2, x3, y3 );

id_1 = 40; id_2 = 41; id_3 = 42;
GuiRadio( "Radio 1", id_1, 10, 30, 100, 20, 1 );
GuiRadio( "Radio 2", id_2, 10, 50, 100, 20, 1 );
GuiRadio( "Radio 3", id_3, 10, 70, 100, 20, 1 );

GuiCheckBox( "Check 1", 50, 10, 110, 100, 20, 1 );

if( clickevent && id0 >= id_1 && id0 <= id_3 ) {
	// radio button toggle
	StaticVarRemove( "check*" );
	radioON = GuiGetCheck( id0 ) == 1; 	
	if( id0 == id_1 || id0 == id_2 || id0 == id_3 )	
		StaticVarSet( "check" + id0, radioON, persist );
}

// execute activated radio button at each refresh
per = 0;
if( StaticVarGet( "check" + id_1 ) ) {
    per = per1;   
}
if( StaticVarGet( "check" + id_2 ) ) {
    per = per2;   
}
if( StaticVarGet( "check" + id_3 ) ) {
    per = per3;  
}

calculateSineFunction( per );
rsine = getSineFunction(); 

_Trace( "Radio 40, 41, 42: " + GuiGetCheck( 40 ) + ", " + GuiGetCheck( 41 ) + ", " + GuiGetCheck( 42 ) + " Check 50: " + GuiGetCheck( 50 ) );

GraphXSpace = 5;
SetChartBkColor( colorBlack );
Plot( rsine, "", colorBlue, styleLine, Null, Null, 0, 0, 2 );

#40

okidokie, thanks,will respond tomorrow


#41

Ed, here I’ve made new version 1.3 that includes reset to default button (if clicking reset or on (initial) start of AmiBroker). If setting persist variable of line 9 to 1 then it keeps set radio button and its according plot (both ones on restart of AB). You can set default reset ID in line 15.

/// @link http://forum.amibroker.com/t/amibroker-6-25-0-beta-released/1362/40
// Persistent Radio Buttons
// by empottasch & fxshrat
// version 1.3

Version( 6.25 );
RequestTimedRefresh(1);

persist = 0;// 0 (false) or 1 (true) for persistent vars
per1 = Param( "Period 1", 20, 1, 500, 1 );
per2 = Param( "Period 2", 80, 1, 500, 1 );
per3 = Param( "Period 3", 300, 1, 500, 1 );
reset = ParamTrigger( "Reset", "Press Here" );
id_1 = 40; id_2 = 41; id_3 = 42;
default_id = id_1;// set default reset ID here

function calculateSineFunction( per ) {
    ff = sin( 2 * ( 4 * atan( 1 ) ) * Cum( 1 ) / per );
    StaticVarSet( "sinefunc", ff );
}

function getSineFunction() {
    return StaticVarGet( "sinefunc" );
}

id0 = GuiGetEvent( 0, 0 );
id1 = GuiGetEvent( 0, 1 );
clickevent = id1 == 1;

GfxSelectSolidBrush( colorBrightGreen );
GfxRoundRect( x1 = 0, y1 = 25, x2 = 80, y2 = 95, x3 = 5, y3 = 5 );

GuiRadio( "Radio 1", id_1, 10, 30, 100, 20, 1 );
GuiRadio( "Radio 2", id_2, 10, 50, 100, 20, 1 );
GuiRadio( "Radio 3", id_3, 10, 70, 100, 20, 1 );

sumid = 0;
staticradioname = "GuiRadio_Check_";
// check whether any radio button is selected
for( i = id_1; i <= id_3; i++ ) { 		
	GuiSetCheck( i, 0 );// uncheck all radio buttons before setting new one
	sumid += Nz(StaticVarGet( staticradioname + i ));
}
resetcond = reset || sumid == 0;
	
// radio button toggle	
if( clickevent && id0 >= id_1 && id0 <= id_3 || resetcond ) {	
	StaticVarRemove( staticradioname + "*" );
	if( resetcond ) {// if resetting or no radio button selected
		StaticVarSet( staticradioname + default_id, 1, persist );	
	} else // if setting new radio button
		StaticVarSet( staticradioname + id0, 1, persist );	
}

// set radio button (i.e on intial start of AB or on insert or re-insert of AFL)
for( i = id_1; i <= id_3; i++ ) {		
	if( Nz(StaticVarGet( staticradioname + i ) != 0 ) )	{
		// update static var
		StaticVarRemove( staticradioname + "*" );
		StaticVarSet( staticradioname + i, 1, persist );
		GuiSetCheck( i, 1 ); // set radio button		
		break;
	}
}

n = 1;
per = Null;
// execute activated radio button at each refresh
for( i = id_1; i <= id_3; i++ ) {
	if( GuiGetCheck( VarGet("id_" + n) ) == 1 ) 
		per = VarGet( "per" + n ); 
	n++;
}

calculateSineFunction( per );
rsine = getSineFunction(); 

_Trace( "Radio 40, 41, 42: " + GuiGetCheck( id_1 ) + ", " + GuiGetCheck( id_2 ) + ", " + GuiGetCheck( id_3 ) );

GraphXSpace = 5;
SetChartBkColor( colorBlack );
Plot( rsine, "", colorBlue, styleLine, Null, Null, 0, 0, 2 );

#42

hi fx,

thanks for that works good. I have not looked at your code in detail yet. One reason is that I read out of Tomasz’s response that there will be some changes in the next beta. In my opinion my original code, which was using GuiGetCheck should have worked (right?). Or did I make a mistake there? Yesterday I got the impression that you avoided using GuiGetCheck and was using static vars instead (to overcome the fact GuiGetCheck was returning unexpected values).

I will check your solution in more detail but started working today on a GFX version as a temporary solution. I made instead of buttons like GuiButton a button called GfxButton with the same parameters, same with GuiSetColors => GfxSetColors etc etc. but will just be simplistic version


#43

As I wrote GuiGetCheck in 6.25.0 may sometimes return -1. If it returns -1 it means “no change since last time”. Next beta won’t do that.


#44

I’m using Windows 10 Home 64 Bit. Amibroker 6.25 (64 Bit)

I’ve got several formulas that have GUIButtons and I have noticed that I can not use the delete key on the keyboard to delete a trend line. I also cant use any custom keyboard shortcuts.

Recently I was using Amibroker 6.22 (64 Bit) and I didn’t have any of these problems.

I’m also noticing that in version 6.22 and 6.25 that the ends of a trend line will flicker while I am drawing it. Is this something to do with RequestMouseMoveRefresh();


#45

thanks, yes that was actually my problem that the buttons all return -1 when you click on the chart area outside of the button area. Indeed you can make it work using static variables but as far as I can see it all gets very complicated unnecessarily. Unless of course this (return of -1 ) is normal procedure for some other reason that I am unaware of.

very nice code fx, but I’ll wait for the next beta, I want to keep it more simple. What I however still don’t understand: getting back to my initial simple code at startup I set button id_1 and id_4. From the Trace() I can see they are indeed set but the set does not show up in the buttons. However, when I press the reset button then they show. Why is that?

reset = ParamTrigger( "Reset", "Press Here" );

id_1 = 40;
id_2 = 41;
id_3 = 42;
id_4 = 50;
id0 = GuiGetEvent( 0, 0 );
id1 = GuiGetEvent( 0, 1 ); // returns notify code
clickevent = id1 == 1;

GuiRadio( "Radio 1", id_1, 10, 30, 100, 20, 1 );
GuiRadio( "Radio 2", id_2, 10, 50, 100, 20, 1 );
GuiRadio( "Radio 3", id_3, 10, 70, 100, 20, 1 );

GuiCheckBox( "Check 1", id_4, 10, 110, 100, 20, 1 );
GfxSelectSolidBrush( colorBrightGreen );
GfxRoundRect( x1 = 0, y1 = 30, x2 = 100, y2 = 130, x3 = 5, y3 = 5 );

// at startup or reset
if( Nz( StaticVarGet( "startval" ) ) == 0 OR reset == 1 )
{
    Say( "startup" );
    StaticVarSet( "startval", 1 );

    GuiSetCheck( id_1, 1 );
    GuiSetCheck( id_4, 1 );
}

// radio toggle
if( clickevent )
{
    for( i = id_1; i <= id_3; i++ )
    {
        if( i == id0 ) GuiSetCheck( i, 1 );
        else GuiSetCheck( i, 0 );
    }

    if( id0 == id_4 ) GuiSetCheck( id_4, 1 );
    else GuiSetCheck( id_4, 0 );
}

_Trace( "Radio 40, 41, 42: " + GuiGetCheck( id_1 ) + ", " + GuiGetCheck( id_2 ) + ", " + GuiGetCheck( id_3 ) + " Check 50: " + GuiGetCheck( id_4 ) );