Login Page - Create Account

Support Board


Date/Time: Tue, 22 Apr 2025 17:24:10 +0000



Post From: C++, ACSIL functions question

[2023-03-11 13:24:38]
BenjFlame - Posts: 337
Hi, here is the skeleton of a basic ACSIL study.


#include "sierrachart.h"

SCDLLName("Custom Studies")

SCSFExport scsf_tradeLogger(SCStudyInterfaceRef sc)
{

if (sc.SetDefaults)
{
}


int variableA = 1;


int myFunction() // Definition. Wants to access variableA
{
int newvar = variableA + 2;
return newvar;
}

myFunction(); // call


}

Is there any way for myfunction() definition to access variableA without passing it as parameter? Or is it an obligation to pass to the function each and every variables it is going to use? C++ Lambda, could this be a solution?
I'm confused because I come from another language where you can access freely any variable in the scope just higher.
Date Time Of Last Edit: 2023-03-11 14:36:48