Login  Register

Re: String representation of Class

Posted by HilaireFernandes on Nov 12, 2014; 9:18am
URL: https://forum.world.st/String-representation-of-Class-tp4789773p4789786.html

Thanks, interesting hack I need to learn from.

Filout works well as long as only ascii appear in the body of the
method. When a method contains non ascii (for example for a string)
fileout get irrational with a ZNInvalidUTF8, but not always!

For example, a script method as:

scriptName
^ 'téte'

does not lead to the error, but as following:

scriptName
^ 'tété'

leads to the error.


Note the scriptName method works from Pharo

To build the script I use the following code.

createScriptFrom: dialog
"Build a new script from the dialog, return the newly created script object"
        |scriptClass stream|
        scriptClass := DrGeoUserScript
                subclass: ('DrGeoScript', dialog scriptName hash printString) asSymbol
                instanceVariableNames: ''
                classVariableNames: ''
                category:  'DrGeoII-User'.
        "name"
        stream := WriteStream on: String new.
        stream << 'scriptName'; << Character cr;
                << Character tab; << $^; <<$'; << dialog scriptName; << $'.
        scriptClass compile: stream contents classified: 'public'.



Later I test directly from the browser  with a dummy class with one
method with non ascii character. Fileout sometimes work (for example, I
add a space in the method body, save, remove the space, save again,...),
some time not.

tested on Pharo 3.0

Hilaire





Le 12/11/2014 09:33, Sven Van Caekenberghe a écrit :
> String streamContents: [ :out | Association fileOutOn: out ]
>
> I am not sure it covers everything, but for some script methods this will do.


--
Dr. Geo - http://drgeo.eu
iStoa - http://istoa.drgeo.eu

PharoDebug.log (292K) Download Attachment
Edit script.png (92K) Download Attachment