Welcome to Macrobject Community Login | Register | Faq  

    Macrobject Community
  Macrobject Software Knowledge Management and Collaboration Platform
Search    
   

Re: Defining global variables that span multiple units
Started by wasuplee123 at 07-21-2008 8:31 PM. Topic has 1 replies.

Print Search « Previous Thread
  07-21-2008, 8:31 PM
wasuplee123 is not online. Last active: 9/9/2008 9:31:45 AM wasuplee123

Top 25 Posts
Joined on 06-04-2008
Posts 8
Defining global variables that span multiple units
Reply Quote
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.

   Report 
  07-22-2008, 1:50 AM
Bill is not online. Last active: 12/18/2009 11:43:49 PM Bill

Top 10 Posts
Joined on 06-28-2008
Posts 15
Re: Defining global variables that span multiple units
Reply Quote
/// ===================================
/// 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
/// ===================================
   Report 
Post
Macrobject Comm... » Developing Tool... » Nuva Language » Re: Defining global variables that span multiple units

Powered by Community Server, by Telligent Systems