Skip to main content

NRC_JobfileInsertIF(int line, int port, int value)

Insert IF instruction into the job file

Before calling this function, please call NRC_CreateJobfile(std::string jobname) or NRC_OpenJobfile(std::string jobname) to create or open a job file

It needs to be used with NRC_JobfileInsertENDIF(int line)

Type

int=>Insert IF instruction into the job file

Return valueDescription
0The function is called successfully
-101Invalid input parameter
-102The target object does not exist. This typically occurs when the system initialization is incomplete, and calling other functions may return this value
-103The target object is currently in an inoperable state

Parameter Option

ParameterTypeDescription
lineintThe line number where the instruction will be inserted, parameter range: 0 < line < (NRC_GetJobfileLineSum()+1)
portintThe number of the digital input port to be detected, parameter range: port > 0
valueintInput status to be checked; 0 represents low-level input state; 1 represents high-level input state

Sample code

//If the IF condition is met, execute the IF code block, otherwise execute the ELSE code block; if there is no ELSE instruction and the IF condition is not met, the IF code block will be skipped, and the instruction after ENDIF will be executed directly
NRC_JobfileInsertIF(1, 5, 1);
NRC_JobfileInsertMOVJ(2, 100, pos1, 0);
NRC_JobfileInsertDOUT(3, 1, 0);
NRC_JobfileInsertELSE(4);
NRC_JobfileInsertMOVL(5, 100, pos2, 0);
NRC_JobfileInsertTIMER(6, 0.5);
NRC_JobfileInsertENDIF(7);