Jump to content
OMRON Forums

DBMasterC

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by DBMasterC

  1. I've been investigating using the script System call to invoke some background C programs and do some work, however I'm running into behavior contrary to the documentation. The manual includes this example: system"/opt/ppmac/tune/parabolicmove 1 2000 500 0 0 0"; However, when executed, I get an error that sh: /opt/ppmac/tune/parabolicmove 1 2000 500 0 0 0: No such file or directory This isn't super surprising; sh is being passed the entire string and is interpreting it as the executable to find, rather than as an executable followed by arguments. If I just move the quote: system"/opt/ppmac/tune/parabolicmove" 1 2000 500 0 0 0; this works fine - the executable is invoked with the right arguments. Now, the crux is the other feature advertised in the manual, the ability to pass a formatted string with arguments to system. Ideally, I'd do something like system"/opt/ppmac/app/doWork %d %d %d",pVariable1,pVariable2,pVariable3 This doesn't work for two reasons: system "/var/ftp/usrflash/foo.out %d %d %d",10,20,30 sh: /var/ftp/usrflash/foo.out %d %d %d,10,20,30: No such file or directory The file not being found is expected per the initial issue. However, given that, what I'd _expect_ to not be found is "/var/ftp/usrflash/foo.out 10 20 30" rather than the full pattern. How can I format a command to the system from script? Am I doing something wrong? Is the manual wrong?
  2. My hacky solution involves abuse of the switch construct. While it adds some bloat, it does allow you to return early. Whether or not it's preferable to goto is in the eye of the beholder. sub: doMath(&success) switch(0) { case(0): success = -1 //default is failure local math = 0; if (somethingbad==1) break; //will exit the switch{}, hitting your return if (somethingelse == 1) break; math = 2+2; success = 1; //completed } return;
×
×
  • Create New...