Generating Random Numbers?

  • Is there a way to generate a random number in KRL?
    I've been using a work-around via RSI,
    But no RSI in this project so was trying to figure out a way to hack one in


    KR C4 compact
    KSS 8.3.25

  • AD
  • Hm, not sure what I'm doing wrong, but the CWRITE function keeps spitting out a "Random Value Invalid" error.. Doesn't seem to matter if its inline, subprogram or function..



    Am I doing something wrong? I'm not so versed in Interface functions(?) or anything that uses more than the single .src file so might be fudging something up..

  • Aaand nevermind, forgot to initialize Random. Didn't know that CWrite attempts to read the value before setting it (I think?)
    Just put a Random=0 before the CWrite function and it works now :dance2: thanks!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now