Created
September 17, 2014 12:16
-
-
Save kilon/26ecc36c0377b692a97d to your computer and use it in GitHub Desktop.
a backup for getValue:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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