Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 262 Vote(s) - 3.54 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Infinite loop that reads stdin in JScript

#1
I'm trying to create an infinite loop to poll for midi input. The loop I have here is technically infinite but I think what's happening is it's getting stuck on the WScript.StdIn.ReadLine() method. It seems that it waits each time for the user to enter something before it continues. I think this because when I enter a character, any midi input in that instance will get routed and the `WScript.Echo` message will go off.

How can I get it to not wait but check in that instance if there's a character or not? so that the loop doesn't get stopped waiting for input. Is there another `ReadLine()` method that would work for what I'm looking for?

Here's the code:

while (true) {
str = WScript.StdIn.ReadLine();
if (str == 'q')
break;
// WScript.StdOut.Write("the while loop continues..."
WScript.Echo("the while loop continues...")

msgStr = mox.GetMidiInput()

if (msgStr !== "") {
msgArray = msgStr.split(",")
tStamp = msgArray[0]
port = msgArray[1]
stat = msgArray[2]
data1 = msgArray[3]
data2 = msgArray[4]

mox.OutputMidiMsg( 3, stat, data1, data2);
} else {
continue;
}
}

EDIT:

Right now I just got rid of the `ReadLine()` because I read on MSDN that it waits for an enter keypress before it returns and I don't think there are any arguments to change that... so I have an infinite loop like I want but I have to resort to ctrl+c to exit it. Anybody have any ideas for a construct that would allow me to quit via the keyboard somehow?

EDIT 2:

I found out that midiox actually provides a method to be polled to exit the script and it works great.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through