Welcome! Log In Create A New Profile

Advanced

Local variable memory size

Posted by damato68 
Local variable memory size
December 03, 2012 12:18PM
Hi,
I need to increase the local variable memory size, I've used
flsys(8,600)
flsave("")
Increasing this block are necessary to reduce any other ?
The question is because I've found a problem at runtime in a function where data from a string variable was lost...

Many thanks for any support.
D.
Re: Local variable memory size
December 03, 2012 03:59PM
Only change the size of variable storage as a last resort. These are balanced, increasing one robs the program space. Local memory is created and destroyed as the function is entered and exited so look at the code and see how a local can take up so much space - look for an alternative.

There is a FAQ with regard to strings being chopped off, this happens because the default string space is only 10 bytes (this is a microcontroller after all).

function test(a$)
 print a$
endf

test(“this is a long string”)

Function test will chop the string as the local variable a$ has only 10 bytes by default to store the string, to cure this use:

function test(a$[40])
  print a$
endf

Now the string will hold up to 39 characters.
Re: Local variable memory size
December 04, 2012 08:52AM
Thanks jimer, because the code complexity that i'm porting from c to basic (a communication protocol) it is not easy to use global variables. However, all buffer are globals, we don't use strings as "strings" but like memory buffer (peekc, pokec). Only local counter, flag, temporary variables are local. For us the best solution would to keep protocol functions as c language as library and use basic only for application user interface and business layer, benefiting of hi level language and graphical library....



Edited 3 time(s). Last edit at 12/04/2012 08:55AM by damato68.
Sorry, you do not have permission to post/reply in this forum.