4D SYSTEMS FORUM

Register New Posts
 
 
 


Reply
 
Author Comment
 
kt88pppamp

Registered: 24/05/12
Posts: 10
Reply with quote #1 
For a custom interface I am writing, I need to know if it is possible to create independent entities of functions and global variables.

I want to create a file with a few functions and have a group of variables only visible to those functions, not the whole program. Is this possible?

Do you do this by making a library?
meldavia

Registered: 18/03/07
Posts: 900
Reply with quote #2 
The compiler there is no formal way of hiding any namespaces, and inherited files are all part of the global name space.
There is a couple of ways to tackle this, first  is to have a main program running from FLASH which contains all you main arrays and variables,
and call up sub functions from disk, passing pointers to the variables in the parent program.

If you just need to hide same name variables in functions, you can use private variables (which are still in the global space,
but act similarly to a static variable in C). The main difference here is that they are still addressable from other functions if required,
you just prepend the variable name with the function name followed by a 'dot'

eg

func myfunc()
var private count;
var provate colour;
......
endfunc

Then those variable are accesible from other functions like:-
myfunc.count++;
c := myfunc.colour;


__________________
Regards,
Dave
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Powered by Website Toolbox - Create a Website Forum Hosting, Guestbook Hosting, or Website Chat Room for your website.