ATTENTION

This FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices.


flexsim.com

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 01-07-2014
Christian Norregaard Christian Norregaard is offline
Flexsim User
 
Join Date: Oct 2011
Posts: 59
Downloads: 13
Uploads: 0
Thanks: 33
Thanked 14 Times in 9 Posts
Rep Power: 115
Christian Norregaard will become famous soon enough
Default Question about iskeydown() command

Hi all.

I am looking for a way to get FlexSim to terminate code execution. (For instance to be able to prevent infinite loops.) I tried doing this in the code below.

The goal was to be able to terminate execution of the code by pressing the left shift key, but I can't seem to get it to work. If the shift key is pressed when I start the code execution, it works, but not if I press while the code executes.

Code:
for(int x=1;x<=10000000;x++)
{
	if(iskeydown(16)) return "Shift Key Pressed";
	int Number = duniform(1,100000000)+duniform(1,100000000);
}
return realtime(12);


Is there any way I can get FlexSim to 'listen' for a keystroke while executing the code?

Best regards
Christian
  #2  
Old 01-07-2014
Carsten Seehafer's Avatar
Carsten Seehafer Carsten Seehafer is offline
FlexSim Geek
 
Join Date: Oct 2008
Location: Ritterhude, Deutschland
Posts: 230
Downloads: 45
Uploads: 1
Thanks: 474
Thanked 320 Times in 143 Posts
Rep Power: 379
Carsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud ofCarsten Seehafer has much to be proud of
Default

Quote:
Originally Posted by Christian Norregaard View Post
I am looking for a way to get FlexSim to terminate code execution.
Please try Ctrl + Break. This shortcut tries to terminate the code execution.
The Following 3 Users Say Thank You to Carsten Seehafer For This Useful Post:
Sebastian Hemmann (01-08-2014)


Thread Thread Starter Forum Replies Last Post
a question about changetask command oliver xie Q&A 6 07-13-2012 02:25 AM
family command? zhang xin Q&A 0 01-14-2010 06:33 PM
a question about the command "getitemtype" Vic Li Q&A 2 10-04-2008 11:47 PM
releaseitem command AlanZhang Q&A 3 10-04-2007 10:11 AM


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.