// Lit2 $LIT2::WaitTime = 2; // Seconds function rubyCmp(%first, %second) { %result = rubyEval("cmp('" @ %first @ "', '" @ %second @ "')"); return getSubStr(%result, 0, 1); } function rubyExec(%file) { %data = ""; %handle = new FileObject(); %handle.openForRead(%file); while (!%handle.isEOF()) %data = %data @ %handle.readLine(); return rubyEval(%data); } function rubyGetValue(%value, %length) { $temp = ""; $temp = rubyEval(%value); return $temp; } function rubyEval(%expression) { %connection = new TCPObject(LIT2Client) { connected = false; }; %connection.connect("127.0.0.1:2000"); %expression = %expression @ ""; %connection.send(%expression); %connection.disconnect(); %received = false; %response = ""; %countedSeconds = 0; %currentSeconds = formatTimeString("ss"); while (!%received) { %newSeconds = formatTimeString("ss"); if (%newSeconds != %currentSeconds) { %countedSeconds++; %currentSeconds = %newSeconds; } if (%countedSeconds >= $LIT2::WaitTime) return ""; %handle = new FileObject(); %handle.openForRead("lit2.txt"); %data = %handle.readLine(); %ending = strStr(%data, ""); if (%ending > -1) { %response = getSubStr(%data, 0, %ending); %received = true; } %handle.close(); %handle.delete(); } %handle = new FileObject(); %handle.openForWrite("lit2.txt"); %handle.writeLine(""); %handle.close(); %handle.delete(); return %response; } function LIT2Client::onLine(%this, %line) { if (%line !$= "") %this.last = %line; } function LIT2Client::onConnect(%this) { } function LIT2Client::onDisconnect(%this) { %this.delete(); } function LIT2Client::onConnectFailed(%this) { error("LIT2 Connection Failed---"); }