PropBasic: Using multiple instances of lib
VonSzarvas
Posts: 3,525
Asking a question with an example:
A main cog and 2 tasks(cogs) all require separate serial ability.
The serial.lib library is a very useful import. However, it can only be imported once to the entire project - it means the PIN (tx/rx) & CON (baud) are the same.
If the different cogs/tasks required serial "action" to different external serial devices, then the lib stradegy falls short.
As I can see, I would need to copy the serial.lib and search/rename all the CON,PIN,VAR and SUB/FUNC definitions (perhaps serial1.lib, serial2.lib, serial3.lib)
Is this the only way to handle this at the moment ?
__________________________________________________________________________
-- Idea:
Could the library be LOADed with an option, such as:
LOAD "serial.lib" { prefix="debug", TX="10", BAUD="T57600" }
So during the LOAD, all VAR,CON,PIN,SUB,FUNCS are prefixed (ie. TX_BYTE becomes debugTX_BYTE) and obviously TX PIN is set to 10, etc... )
Now we can use our serial lib, ie. debugTX_DEC tmp
Would this be useful... am I making a mountain from a molehill ?!
A main cog and 2 tasks(cogs) all require separate serial ability.
The serial.lib library is a very useful import. However, it can only be imported once to the entire project - it means the PIN (tx/rx) & CON (baud) are the same.
If the different cogs/tasks required serial "action" to different external serial devices, then the lib stradegy falls short.
As I can see, I would need to copy the serial.lib and search/rename all the CON,PIN,VAR and SUB/FUNC definitions (perhaps serial1.lib, serial2.lib, serial3.lib)
Is this the only way to handle this at the moment ?
__________________________________________________________________________
-- Idea:
Could the library be LOADed with an option, such as:
LOAD "serial.lib" { prefix="debug", TX="10", BAUD="T57600" }
So during the LOAD, all VAR,CON,PIN,SUB,FUNCS are prefixed (ie. TX_BYTE becomes debugTX_BYTE) and obviously TX PIN is set to 10, etc... )
Now we can use our serial lib, ie. debugTX_DEC tmp
Would this be useful... am I making a mountain from a molehill ?!
Comments
What I might try to do (if it's possible) is to allow something like:
Bean
One thought... The "AS" name could be "debug_" or "debug",
thus the PIN would be defined debug_TX or debugTX
So, the user could decide if they wanted the underscore or not by specify the prefix at the AS statement. I mean, perhaps it should not (nor need not) be forced.
...anyhow, don't want to make a meal of it! If you come across a solution and have time to implement, it would be very gratefully received. Hopefully from some other angles there are not issues with this productivity concept.