B4J Question [BANano] BN() not returning the generated variable name

B4JExplorer

Active Member
Licensed User
Longtime User
Hi,

I'm just playing with a few Banano code-generating functions. One of them, BN(), doesn't seem to be returning anything.


Log( "Variable name " & BANano.BN( "testvar" ) )


This should return

"_bncodegeneration_first_testvar"

(
, but is empty, it's just returning "Variable name".

What am I doing wrong?


fyi, the js and html files themselves are being generated, along with all the expected code.
 

B4JExplorer

Active Member
Licensed User
Longtime User
Can you share some more code? It was meant for classes (seemed like the only thing who needed it). What is testvar and why would you need to use it like this?

testvar is not an actual variable used in the project.

I threw the log statement in there, to watch BN() return the name that the variable WOULD be called, after the code generation. This log statement was written in the AppStart() routine.

Am I misunderstanding the purpose of bn()? Should it return, INSIDE the B4J project, the name of the variable when it's written in the js code, after the Build is executed?

The code itself is being generated as expected. e.g. the index.html file (although I called it index.php, because the php generation isn't working yet), and a button defined in the InitialBody. And the test.js code.

I guess the real question is: Is BN() meant to be used inside the generated javascript, or inside the b4j project?
 
Upvote 0

Mashiane

Expert
Licensed User
Longtime User
This log statement was written in the AppStart()
The code written in AppStart is NEVER compiled into a BANano project source code (as per BANano posts) it is just there to set up the project for BANano and other things. I made this mistake too so many times. ;). Create a module / class and test again as that will be compiled into the javascript project needed. I'm sure with that correction things will be fine..

Good luck!
 
Upvote 0

B4JExplorer

Active Member
Licensed User
Longtime User
The code written in AppStart is NEVER compiled into a BANano project source code (as per BANano posts) it is just there to set up the project for BANano and other things. I made this mistake too so many times. ;). Create a module / class and test again as that will be compiled into the javascript project needed. I'm sure with that correction things will be fine..

Good luck!
Very good point. There's no logical reason why any expected code would be displayed during the execution of AppStart.

Ok, I'll try it in a separate class, thanks Mashiane.
 
Upvote 0
Top