B4A

Mostrando las entradas con la etiqueta tips. Mostrar todas las entradas
Mostrando las entradas con la etiqueta tips. Mostrar todas las entradas

miércoles, abril 07, 2010

Pharo/Squeak Tips - Counting lines of code

I will try to publish here some tips I found useful and that may be of help to others. Of course, some of them, will be very basic, but still may be useful for newbies.

Said that, a thing that I like to know is the approximate lines of code of my projects, the lines of code I write in a period of time, etc. 

To know that you can use the following code:

Being, in this case, 'G1' the two letters that identify all the classes of the project I want to measure.

The output looks like:


Ok, now you can measure how many lines of Smalltalk code you write at day! :)

domingo, noviembre 30, 2008

More tips to get graphics inside the image

Some time ago I already talked about this topic. But what happens when the graphics is a bit big and the usual #printString, #fullPrintString, #longPrintString only show the first 5000 chars and ends with "etc..."

We talked about this topic with Jecel on the Squeak IRC and also with Nico Petton, who suggested this way to avoid the "etc..."

The trick is having the string on a text file, and then copy from them. The code that make the job is the following:

jueves, junio 29, 2006

Algunos tips sobre manejo de gráficos en Squeak y Seaside

Una forma de mostrar gráficos (png, jpg) es leyéndolos desde el disco rígido, sin embargo, es mucho más cómodo incluirlos en algún método de nuestros objetos en forma de código fuente, de manera que los podamos tener disponibles cada vez que instalemos nuestro código en una nueva imagen.

La forma de hacerlo es la siguiente:

myMethod



x := Form fromFileNamed:'reload.png'.

xArray := x bits asArray.



^ ShoreForm

extent: 32@32

depth: 32

fromArray: xArray

offset: 0@0.


El código es muy simple y se explica por si mismo (en el ejemplo reemplazamos el logo de ShoreComponents por uno propio).

Como usamos la clase Form para esta tarea y la misma trabaja con imágenes de tipo gif, seguramente vamos a tener problemas de definición en los íconos que veamos desde Seaside, lo cual se arregla reemplazando el método asMIMEDocument de la clase Form, de la siguiente manera:

asMIMEDocument

| aStream rw |

aStream := RWBinaryOrTextStream on: String new.

rw := PNGReadWriter on: aStream.

rw nextPutImage: self.

rw close.

aStream reset.

^MIMEDocument contentType: 'image/png' content: aStream contents

Gracias a Diego por este último tip.