Hello list. I want to be able to bring some css and png files to the Smalltalk environment as methods.
In Squeak I used to use the InstanceEncoder package to encode and decode files or instances of any object that can be streamed to methods. See http://map.squeak.org/package/e9e852e1-27d9-412c-8efe-212891832d07 It is used like this (from the page above):
"Store a form as a class-side method"
"Then in the instance-side of MyClass you can access this MIME-encoded object as if it is a regular Smalltalk object" "instance variable 'picture' now is automatically reconstituted from the MIME-encoded stream" Does exist a similar package in VisualWorks?thanks Bill |
William Hubbard wrote:
> Hello list. I want to be able to bring some css and png files to the > Smalltalk environment as methods. > In Squeak I used to use the InstanceEncoder package to encode and > decode files or instances of any object that can be streamed to > methods. See > http://map.squeak.org/package/e9e852e1-27d9-412c-8efe-212891832d07 > Here are some packages you may want to explore: http://www.cincomsmalltalk.com/publicRepository/Tools-Resource%20Library.html http://www.cincomsmalltalk.com/publicRepository/Epigent%20File%20In%20Method(Bundle).html http://www.cincomsmalltalk.com/publicRepository/Assets.html http://www.cincomsmalltalk.com/publicRepository/AssetsManagement.html I found these by typing 'resource' into this search page: http://www.cincomsmalltalk.com/publicRepository/ HTH, Reinout ------- |
In reply to this post by William Hubbard
You can get the
contents of a file as ByteArray, then send that #storeString.
rs := myFilename readStream binary.
byteArray := [rs contents] ensure: [rs close].
byteArrayString := byteArray storeString.
For arrays bigger
than 200 bytes #storeString uses #asPackedString to create a string and the
code to reconstitute the bytes from the string. See ByteArray>>storeOn:,
#asPackedString and #fromPackedString: for details. It's used by
UIMaskEditor>>installInSystem to turn an Image into a method, with
something like:
myClass
compile: ('myMethodName\ ^' withCRs,
byteArrayString) classified: #'resources'
Another approach is
to use Store to version the files, by attaching them to a bundle. This keeps
things as CSS and PNG files on the disk: they're picked up from the disk when
you publish (if you tell Store they've changed), and downloaded to the disk when
you load (Store will prompt for overwrite, directory creation etc.). The UI for
this is poor, and you can only do it with bundles, not packages. Search for
'external file' in doc\SourceCodeMgmtGuide.pdf in VW 7.5, or in the VW 7.3
release notes in earlier versions.
HTH,
Steve
|
In reply to this post by William Hubbard
As previously mentioned, "Epigent File In Method" can be used. It is
described here: http://www.cincomsmalltalk.com/userblogs/runarj/blogView?showComments=true&entry=3360329900 Runar |
Free forum by Nabble | Edit this page |