How to use SmartRefStream

German Arduino gsa at softhome.net
Tue Sep 7 10:14:59 UTC 2004


Hi Edgar!

Seems that my news reader has missed your mail until today!!!!

Sorry by the delay and really thanks you very much by your help.

Gracias Edgar!

Lic. Edgar J. De Cleene wrote:
> Germán:
> You should receive same in Spanish, but someone could find useful.
> 
>>From TEG (complete game 3.6Mb and  code is in SqueakRos
> http://ar.groups.yahoo.com/group/squeakRos/)
> 
> grabaEstado
>     | t1 |
>     t1 _ ReferenceStream fileNamed: 'estado.teg'.
>     t1 nextPut: losJugadores.
>     t1 nextPut: cartasOrden.
>     t1 nextPut: jugadoresVivos.
>     t1 nextPut: playerTurn.
>     t1 nextPut: ronda.
>     t1 nextPut: numCarta.
>     t1 nextPut: cambiosTotales.
>     1
>         to: 42
>         do: [:t2 | 
>             t1 nextPut: (submorphs at: t2) ejercitos.
>             t1 nextPut: (submorphs at: t2) deQuienSoy].
>     t1 close
> 
> leerEstado
>     | t1 |
>     t1 _ ReferenceStream fileNamed: 'estado.teg'.
>     losJugadores _ t1 next.
>     cartasOrden _ t1 next.
>     jugadoresVivos _ t1 next.
>     playerTurn _ t1 next.
>     ronda _ t1 next.
>     numCarta _ t1 next.
>     cambiosTotales _ t1 next.
>     1
>         to: 42
>         do: [:t2 | 
>             (submorphs at: t2)
>                 ejercitos: t1 next.
>             (submorphs at: t2)
>                 deQuienSoy: t1 next].
>     t1 close.
> 
> Same code for sending objects to other TEG instanc3e in other (or same)
> computer network connected.
> 
> askMyData
>     | estadoTEG losPaises losPaisesData elPais soyDe nuevoColor |
>     estadoTEG _ activeSocket getObject.
>     self
>         losJugadores: (estadoTEG at: 1).
>     self
>         cartasOrden: (estadoTEG at: 2).
>     self
>         ronda: (estadoTEG at: 3).
>     self
>         numCarta: (estadoTEG at: 4).
>     self
>         cambiosTotales: (estadoTEG at: 5).
>     losPaises _ estadoTEG at: 6.
>     1
>         to: 42
>         do: [:pais |
>             losPaisesData _ losPaises at: pais.
>             elPais _ self submorphs at: pais.
>             elPais
>                 ejercitos: (losPaisesData at: 1).
>             elPais
>                 deQuienSoy: (losPaisesData at: 2).
>             soyDe _ elPais deQuienSoy.
>             nuevoColor _ (self losJugadores at: soyDe) miColor.
>             elPais redrawInColor: nuevoColor].
> self playerTurn: ( estadoTEG at: 7).
> 
> sendMyData
>     | estadoTEG losPaises elPais losPaisesData |
>     serverOrClient = #server
>         ifTrue: [
>             activeSocket _ socketList at: playerTurn].
>     (activeSocket isValid
>             and: [activeSocket isConnected])
>         ifTrue: [estadoTEG _ OrderedCollection new.
>             estadoTEG add: self losJugadores.
>             estadoTEG add: self cartasOrden.
>             estadoTEG add: self ronda.
>             estadoTEG add: self numCarta.
>             estadoTEG add: self cambiosTotales.
>             losPaises _ Array new: 42.
>             1
>                 to: 42
>                 do: [:pais |
>                     elPais _ self submorphs at: pais.
>                     losPaisesData _ Array new: 2.
>                     losPaisesData at: 1 put: elPais ejercitos.
>                     losPaisesData at: 2 put: elPais deQuienSoy.
>                     losPaises at: pais put: losPaisesData].
>             estadoTEG add: losPaises.
>             estadoTEG add: self playerTurn.
>             activeSocket sendObject: estadoTEG].
>     [activeSocket dataAvailable] whileFalse.
>     self askMyData
> 
> 
> 




More information about the Squeak-dev mailing list