After trying to get VisiGenie to allow my to have unicode user-changable text on buttons, I have moved over to use Visi instead. It does seem easier and I think it will do what I need however in an effort to tidy my experimental code, I have implemented a couple of functions that I can call instead of having all code inline.
If however I try to do anything with a UserButton outside of main(), I get the context error.
For example, if I have the same code within main like this:
" img_SetWord(hndl, iUserbutton1, IMAGE_INDEX, state); // where state is 0 for up and 1 for down, or 2 total states
img_Show(hndl,iUserbutton1) ;"
And also put that code in a subroutine, passing in uUserButton1 as a variable, it complains.
Basic example
#inherit "NoName1Const.inc"
func test(var hndl, var button)
img_SetWord(hndl, button, IMAGE_INDEX, state); // where state is 0 for up and 1 for down, or 2 total states
img_Show(hndl,button) ;
endfunc
func test2(var foo)
test(hndl, iUserButton1);
endfunc
main()
test2(1);
endmain
hndl is a global variable defined in NoName1Const.inc
here is the content of that file:
#CONST
iUserbutton1 // offset 0x0
iUserbutton2 // offset 0x8000
iUserbutton3 // offset 0x10000
iUserbutton4 // offset 0x18000
iUserbutton5 // offset 0x20000
iUserbutton6 // offset 0x28000
#END
var disk, hndl ;
I'm obviously doing something stupid but I can't spot it. Can you help?
I could post the whole of the real program if that helps?.?.
If however I try to do anything with a UserButton outside of main(), I get the context error.
For example, if I have the same code within main like this:
" img_SetWord(hndl, iUserbutton1, IMAGE_INDEX, state); // where state is 0 for up and 1 for down, or 2 total states
img_Show(hndl,iUserbutton1) ;"
And also put that code in a subroutine, passing in uUserButton1 as a variable, it complains.
Basic example
#inherit "NoName1Const.inc"
func test(var hndl, var button)
img_SetWord(hndl, button, IMAGE_INDEX, state); // where state is 0 for up and 1 for down, or 2 total states
img_Show(hndl,button) ;
endfunc
func test2(var foo)
test(hndl, iUserButton1);
endfunc
main()
test2(1);
endmain
hndl is a global variable defined in NoName1Const.inc
here is the content of that file:
#CONST
iUserbutton1 // offset 0x0
iUserbutton2 // offset 0x8000
iUserbutton3 // offset 0x10000
iUserbutton4 // offset 0x18000
iUserbutton5 // offset 0x20000
iUserbutton6 // offset 0x28000
#END
var disk, hndl ;
I'm obviously doing something stupid but I can't spot it. Can you help?
I could post the whole of the real program if that helps?.?.
Comment