I like to use project variables if I am passing data from one macro to the next, but usually this is when I have separate macros that are not sub macros. If I wanted to do a sub macro call, but pass data back, I'd just rewrite the sub macro as a function in the main macro or do as @icse suggested.
But that said, project variables will work with sub macros like this:
// Main macro
FUNCTION Main() {
macro sub.mac
// safety check to make sure sub macro ran properly
if not member($Project._keys, "Data") {
message info "data from sub macro not found."
} else {
message info $Project.Data
}
}
// Sub Macro
FUNCTION Main() {
string data_from_sub = "data"
// Create project variable if it doesn't exist
IF NOT Member($Project._keys, "Data") {
EDIT USERPAR project NAME "Data"
EDIT USERPAR project TYPE 'String'
CREATE USERPAR project
}
$project.Data = $data_from_sub
}
And if you don't want tons of project variables or don't need them after using them then you can always delete it after use with this:
EDIT USERPAR project SELECT "Data"
DELETE USERPAR project SELECTED
Sean WroblewskiApplications Engineer