Hello Folks:
I'm trying to create a function that takes an DINT to dynamically set the range to a random number generator.
Below is the code, I commented out the section I thought would create it as a function.
Thanks for any help!
(*
FUNCTION RandNum
VAR_IN
iMax : DINT;
END_VAR
*)
GSV(Program, MainProgram, LASTSCANTIME, iLastScanTime);
GSV(WallClockTime, , LocalDateTime, arMyTime[0]);
myTime.Microsecond := arMyTime[6];
dRes := SIN(iLastScanTime * myTime.Microsecond);
dRandom := ABS(dRes * 7);
//END_FUNCTION
I'm trying to create a function that takes an DINT to dynamically set the range to a random number generator.
Below is the code, I commented out the section I thought would create it as a function.
Thanks for any help!
(*
FUNCTION RandNum
VAR_IN
iMax : DINT;
END_VAR
*)
GSV(Program, MainProgram, LASTSCANTIME, iLastScanTime);
GSV(WallClockTime, , LocalDateTime, arMyTime[0]);
myTime.Microsecond := arMyTime[6];
dRes := SIN(iLastScanTime * myTime.Microsecond);
dRandom := ABS(dRes * 7);
//END_FUNCTION