Skip to content

Instantly share code, notes, and snippets.

@kilon kilon/getValue
Created Sep 17, 2014

Embed
What would you like to do?
a backup for getValue:
getValue: aString
"similar to sendMessage but this method also return the python value "
|stream errString retValue |
stream := SocketStream openConnectionToHostNamed: '127.0.0.1' port: 4000 .
stream sendCommand: 'RetValue: ',aString.
errString := stream nextLineLf .
[errString matchesRegex: '.*end of error.*'] whileFalse:[
Transcript show: 'iterating with error:',errString ;cr.
(errString matchesRegex: '.*no error.*') ifFalse: [
(errString matchesRegex: '.*end of error.*') ifFalse:[
(errString matchesRegex: '') ifFalse: [
(errString matchesRegex: 'RetValue\:.*') ifTrue:
[Transcript show: ' I am getting error:' , errString ;cr.
(errString regex: '[^(RetValue:)].*' matchesDo:
[ :word| Transcript show: 'Returned' , word;cr. retValue := word]) .
^ retValue] ifFalse: [
self error: errString .]]]].errString:=stream nextLineLf ].
stream close.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.