Fixed variables are not passing the defualt values
All checks were successful
Build / build (push) Successful in 40s

This commit is contained in:
Ankitkumar Satapara
2026-04-29 14:11:08 +05:30
parent a235558db1
commit 7d0b7c3009

View File

@@ -592,6 +592,19 @@ namespace Nodify.Calculator
private void ResolveGetVariableNodes(ICollection<OperationViewModel> allNodes, ICollection<ConnectionViewModel> connections) private void ResolveGetVariableNodes(ICollection<OperationViewModel> allNodes, ICollection<ConnectionViewModel> connections)
{ {
// Seed the variables dictionary with default values from the variable definitions
// so GET nodes return the user-defined default if no SET has been executed yet.
var availableVars = editorViewModel.Calculator.OperationsMenu.AvailableVariables;
foreach (var varInfo in availableVars)
{
if (string.IsNullOrEmpty(varInfo.Title)) continue;
if (!variables.ContainsKey(varInfo.Title) && !string.IsNullOrEmpty(varInfo.DefaultValue))
{
variables[varInfo.Title] = varInfo.DefaultValue;
OnLogMe?.Invoke($"Variable '{varInfo.Title}' seeded with default value: {varInfo.DefaultValue}");
}
}
// Find all GET variable nodes (not in flow chain) and populate their output // Find all GET variable nodes (not in flow chain) and populate their output
foreach (var node in allNodes) foreach (var node in allNodes)
{ {
@@ -606,12 +619,13 @@ namespace Nodify.Calculator
// Check if the variable already has a value // Check if the variable already has a value
if (variables.TryGetValue(varName, out var existingVal)) if (variables.TryGetValue(varName, out var existingVal))
{ {
outputs[node.NodeId] = existingVal?.ToString() ?? ""; var strVal = existingVal?.ToString() ?? "";
outputs[node.NodeId] = strVal;
// Set the output connector value for downstream nodes // Set the output connector value for downstream nodes
var outConn = node.Output.FirstOrDefault(c => c.Shape != ConnectorShape.Triangle); var outConn = node.Output.FirstOrDefault(c => c.Shape != ConnectorShape.Triangle);
if (outConn != null) if (outConn != null)
{ {
if (double.TryParse(existingVal?.ToString(), out double dVal)) if (double.TryParse(strVal, out double dVal))
outConn.Value = dVal; outConn.Value = dVal;
} }
OnLogMe?.Invoke($"GET variable '{varName}' resolved to: {existingVal}"); OnLogMe?.Invoke($"GET variable '{varName}' resolved to: {existingVal}");