Re: Defining global variables that span multiple units
Nuva Language
Defining global variables that span multiple units
wasuplee123
07-21-2008, 8:31 PM
I was wondering how I can define variables that can be shared across multiple units...
These are the units I have:
=========
Main.nuva
-----------
file("My_Functions.nuva", type = Using)
end file
file("Info.pas.nuva", overwrite = true)
target = SchemaName ~ '_Info.pas'
end file
=========
I would like to assign a value to a variable in My_Functions.nuva and be able to read/use it in Info.pas.nuva. It doesn't matter where the variable is defined (either Main.nuva or My_Functions.nuva), as long as My_Functions.nuva can write to it and Info.pas.nuva can read it.
--
I noticed that I can use the System.Runtime.Config variable like this (and it works between units):
System.Runtime.Config.MyTest = "abc";
However this seems to only work for strings... when I try this line, it gives an error message:
System.Runtime.Config.MyTest = System.List.StringList();
--
By the way the "type = using" I copied from another place, without understanding what it is, and it might not actually be what I want.
Re: Defining global variables that span multiple units
Bill
07-22-2008, 1:50 AM
/// ===================================
/// My_Functions.nuva
/// ===================================
var MyGlobalVar; // the global variable
function MyGlobalFunction() // the global function
end function
class MyGlobalClass() // the global class
end class
/// ===================================
/// end My_Functions.nuva
/// ===================================
/// ===================================
/// Main.nuva
/// ===================================
using("My_Functions.nuva")
// now you can use MyGlobalVar, MyGlobalFunction and MyGlobalClass
// in both main.nuva and info.pas.nuva
var MyLocalVar; // you can use MyLocalVar in info.pas.nuva also;
file("Info.pas.nuva", overwrite = true)
target = SchemaName ~ '_Info.pas'
end file
/// ===================================
/// end Main.nuva
/// ===================================