![](http://pdfasset.owneriq.net/e/10/e10b353e-c6e5-4806-ad9e-07fce4310e92/e10b353e-c6e5-4806-ad9e-07fce4310e92-bgad.png)
Chapter 3 173
Programming Examples
Using Java Programming Over Socket LAN
public boolean action(Event evt, Object what) {
// If this is the correct target
if (evt.target == scpiCommand) {
// Get the scpi command
String str = scpiCommand.getText();
// Send it out to the Scpi socket
sck.ScpiWriteLine(str);
String tempStr = str.toLowerCase();
// If command str is "syst:err?", don’t need to send another one.
if ( (tempStr.indexOf("syst") == -1) ||
(tempStr.indexOf("err") == -1) ) {
// Query for any error
sck.ScpiWriteLine("syst:err?");
}
return true;
}
return false;
}
// Start/Stop a Response thread to display the response strings
private void StartResponseThread(boolean start) {
if (start) {
// Start a response thread
responseThread = new Thread(this);
responseThread.start();
}
else {
// Kill the response thread
responseThread = null;
}
}
// Response thread running
public void run() {
String str = ""; // Initialize str to null