Skip to content

Instantly share code, notes, and snippets.

@kilon
Created September 17, 2014 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kilon/26ecc36c0377b692a97d to your computer and use it in GitHub Desktop.
Save kilon/26ecc36c0377b692a97d to your computer and use it in GitHub Desktop.
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