#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

void ucalc_call GetSetting(uCalcBase::Callback cb) {
   // Get the name of the setting to retrieve.
   auto settingName = cb.ArgStr(1);

   // In a real app, this would read from a config file, database, or registry.
   // We simulate it by evaluating another variable in the parent uCalc context.
   auto value = cb.uCalc().EvalStr(settingName);

   cb.ReturnStr(value);
}
int main() {
   uCalc uc;
   // Simulate a host application's configuration store using uCalc variables.
   uc.DefineVariable("AppName = 'uCalc Demo'");
   uc.DefineVariable("Version = '1.2.3'");

   // Define the function that provides a bridge to the 'host'.
   uc.DefineFunction("GetHostSetting(name As String) As String", GetSetting);

   // Use the custom function to build a string from the host settings.
   cout << uc.EvalStr("GetHostSetting('AppName') + ' v' + GetHostSetting('Version')") << endl;
}