Read-only archive of the All About Symbian forum (2001–2013) · About this archive

AppFrame question

5 replies · 1,385 views · Started 07 June 2003

I want to change the CBA titles & callbacks in the middle of the program.

At start of program I have:

AfSetCBAButton;(1,"title1",0,0,"proc1"😉

and CBA 1 displays title1 and jumps to proc1 when pressed.

Then I change it by:

AfSetCBAButton;(1,"title2",0,0,"proc2"😉
The title does not change but proc2 is executed when pressed.

Also:
AfSetTitle: doesn't change application title once it is set

Any ideas?

10x in advance,
NBP

Strange .. it does for me :s

Just checked my code and I don't seme to do anything special to make it work except:

[code:1]
AfSetStatus%:(2)
AfSetCBAVisible%:(1)
AfSetStatusVisible%:(1)
AfSetTitleVisible%:(1)
[/code:1]

In the beginning of my code.

OK, I've found the problem. It was somewhere else, and I think discovering where the problem was would be beneficial to those who wish to "structure" their OPL programs, so here's what's happened.

As I posted some time ago, I'm trying to isolate the services provided by the "core" from the functionality of the application itself. This should prove a good practice, as once you have a working core, you can translate it and just LOADM it into your program.

My core (adopted thankfully from FreEpoc) has something like that:

AfSetCBAButton😞KCBAButton_1%,G_CBA_Title1$,0,0,"HandleCBA"😉

where KCBAButton_1% is a CONST defined in the core, and G_CBA_Title1$ is a GLOBAL defined in the application (remember: the core and the application are two different modules).

Further on in the core, in the HandleCBA😞button&amp😉 proc I have:

IF button&=KCBAButton_1% AND len(G_CBA_PROC1$)>0
@(G_CBA_PROC1$):
ENDIF

where G_CBA_PROC1$ is a GLOBAL defined in the application and contains the name of the proc to execute when CBA1 is pressed. This proc (the CONTENTS of G_CBA_PROC1$) resides in the application module.

Now when I wanted to change the title of CBA1 and the proc to be executed, I just put the following in my application:

G_CBA_Title1$="New Title"
G_CBA_PROC1$="other_proc"
AfSetCBAButton😞KCBAButton_1%,G_CBA_Title1$,0,0,"HandleCBA"😉

The above statements were in a proc called by the HandleCBA itself.
If this sounds too complicated, just bear in mind that I wanted to change the titles & procs of the CBAs when CBA1 was pressed, so the code was put in the G_CBA_PROC1$ proc.

And here was the catch:
KCBAButton_1% was defined as CONST only in the core, so the last statement above (AfSetCBAButton) should have caused an error (undefined extrnal), But since it was called from a callback proc, it didn't stop on the error and didn't show it, it just ignored it, thus not changing.

Here are the 2 scenarios:

Scenario1:
----------
Proc Main:
Proc1:
ENDP

Proc Proc1:
AfSetCBAButton😞x%,G_CBA_Title1$,0,0,"HandleCBA"😉
ENDP

This will cause undefined external error on x%

Scenario2:
----------
const x%=1
Proc module:
AfSetCBAButton😞x%,G_CBA_Title1$,0,0,"HandleCBA"😉
endp

proc HandleCBA:
Proc9:
endp

complied into module.opo

proc Main:
loadm "module"
endp

Proc Proc9:
AfSetCBAButton😞x%,G_CBA_Title1$,0,0,"HandleCBA"😉
ENDP

This will NOT cause undefined external error on x%

Too long a post, I hope someone will benefit from it.

NBP

You shouldn't use
[code:1]
G_CBA_Title1$="New Title"
G_CBA_PROC1$="other_proc"
AfSetCBAButton:(KCBAButton_1%,G_CBA_Title1$,0,0,"HandleCBA")
[/code:1]

For the reason that you want to split off application and core.

Better to make an extra function for it (might seem useless but your code will be split up very nicely)

[code:1]
Set_CBA(1,"New Title","other_proc")
[/code:1]

not that it makes a big difference, but it would have solved your problem 😃

Yes, u'r right. But what solved the problem was:

AfSetCBAButton😞1,G_CBA_Title1$,0,0,"HandleCBA"😉

The culprit was KCBAButton_1% which was defined in the core module but not in the application module, as I tried to describe (seemingly in a too vagued fashion) in the first post of this thread 😞

NBP