nettogrisen
Lifetime Supporting Member
Hi
First time with SCL, so bear with me.
I'm trying to load the digital input image (using piw) into an array.
This is what I have so far:
but it won't compile.
It says "Invallid types of addresses" on this line:
DB100.AlmArray[almNo].almHigh := (PIW0 & (2**almNo));
Can i cast it somehow?
This is what I would have done in c++:
and that works fine.
First time with SCL, so bear with me.
I'm trying to load the digital input image (using piw) into an array.
This is what I have so far:
FUNCTION FC100 : void
// Load DI image into alarm array
VAR_TEMP
almNo : INT; // Alarm number
END_VAR
FOR almNo := 0 TO 15 BY 1 DO
DB100.AlmArray[almNo].almHigh := (PIW0 & (2**almNo));
END_FOR;
END_FUNCTION
but it won't compile.
It says "Invallid types of addresses" on this line:
DB100.AlmArray[almNo].almHigh := (PIW0 & (2**almNo));
Can i cast it somehow?
This is what I would have done in c++:
#include <iostream>
#include <cmath>
using namespace std;
int main() {
bool almArray[16];
int almNo;
int input = 13; // 1101
for(almNo = 0; almNo < 15; almNo++) {
almArray[almNo] = ((int)pow(2, (double)almNo) & input);
cout << almArray[almNo] << \"\\n\";
}
return 0;
}
and that works fine.