Tuesday, December 21, 2004

Writting better code but..


In code, sometimes you write bizarre but faster code:

let's say:

c = Jaca(Ovo(math.exp(HORRORS/TERRORS+1)+1));

where x = (HORRORS/TERRORS). You avoid using memory for an extra variable. But...

In math, if x is expressed as above, only an idiot would prefer to type HORRORS/TERRORS to
x. HEHEHEHHE I have seen with my own eyes someone saying that writting x is very confuse and that's not obvious that an expression with x instead of (HORRORS/TERRORS) is much clear to read ROTFL!!!!!!!!!!!!!!!!!!

Monday, December 20, 2004


Lately, I haven't been able to code at my job, as I've been writting manuals. But as we're heading to a break due to Holydays I got some time to dig ASP.NET better- they don't mind if it is for a work purpose as we have some electronic control written in ASP. It is interesting to convert it to a better style). I always enjoyed C#, but ASP.NET was a bit weird for me. But now, I got how interesting it is for web programmers. I use:

web matrix

you may design very complex pages easily and still have control over your code. God, I am even tempted to code XML again. Hey Nicolas, if you read this, I am trying to dig your code deeper,
just be patient please.

There's gotta be something wrong with me as I am becoming more and more a Microsoft fan. However, I think that ASP.NET owes a lot more to that Borland Delphi guy than to Bill Gates.
But no, I won't use IE.

Tuesday, December 14, 2004


I am not a graphic artist, nor I am a web designer ( not professional at least) but I had this itchy on my fingers and a voice saying "tableless...".

So it used to be :


Now it is:


With two collumns I think I should have never used tables. Or frames. It is interesting that I can design a css/XHTML page to match a layout made on photoshop but that I suck incredibly when trying to layout. That's why I try simple layouts.

Not because I can't afford DreamWeaver, I rather prefer to code it by hand so tableless might imply a bit more work than tables. But as you have a basic layout it is easier to improve it from a root CSS tableless file than one made of tables.

But I don't mind. Lots of sites, even the biggest ones, still use tables. Gmail uses frames, Orkut uses tables and font tags.

On a complete different issue, I am getting tired of Java as I go enjoying C#. Unfortunately I don't feel like coding anything lately. I still owe Nicolas Colombain a few code lines and also
C# keeps me hauting every day.

I am also trying to buy a bass guitar. A 5 string one. To achieve it, I will have to sell my N2 Washburn Guitar. I am a big enthusiast of bass and also have written many bass lines for
my music, so it is time to finally get a bass... When I try out an harmony I usually prefer my acoustic guitar.

Dra. M. Silvia says that I need to run or do something to release the anger I feel here at my job.

Bass playing helps.

Monday, December 13, 2004


I would say that 2004 was the worst year of my life, except if I didn't think of my son. He's not just my son but he's already my best friend, despite being only 2 years old.

I see no reason whatsoever to think that 2005 will be a better year.

My wish list (which I am not likely getting ) :

- Quantum Leap Seasons 1 and 2 DVDs
- Babylon 5 All seasons DVDs
- Stargate All seasons DVDs
- Python Pratical Programming
- C# How To Program
- An air conditioned

I saw Harry Potter 3 and Underworld this weekend. The first is always amusing and this time, I thought it was a little weaker than parts 1 and 2 but still quite interesting. Underworld might sound as a typical gore or horror movie, however it goes beyond the description. Werewolves and vampires are at war for centuries, but it is a multilayer film. Also, the makeup effects, used rather than digital art makes it a decent product of entertainment. I like a story if it makes me feel I am inside it, and UNDERWORLD got it.

Every year I make a real good effort to send people merry Xmas and happy new year. Man, I even put Xmas themes on my web site. This year, nothing I promise.

Wednesday, December 08, 2004

Why should I work with a cold?

I won't thank God for the wheater here at Sertaozinho. After all, it's the idiots that live here (that screwed up the vegetation so much, planting sugar cane with all the bad that comes from it), that I blame for destroying a large portion of my state.

There is a house close to where I work and there used to be a large tree, which spread a wide shadow where I used to park my car. The owner of the house is an old angry man, and he didn't like that other people than him parked their cars "in his own shadow". hehe So he cut off the tree. Yeah, here in Sertaozinho, they don't mind cutting off trees. As a whole, they are dumber than average and add to it that most people here has never learned manners.

So, I am not proud of this town. I hate it. 40 C under the sun and the rain does not come.

Gotta love it, huh?

Tuesday, December 07, 2004

Don't give up

Don't Give Up Lyrics

by Peter Gabriel

in this proud land we grew up strong
we were wanted all along
I was taught to fight, taught to win
I never thought I could fail

no fight left or so it seems
I am a man whose dreams have all deserted
I've changed my face, I've changed my name
but no one wants you when you lose

don't give up
'cos you have friends
don't give up
you're not beaten yet
don't give up
I know you can make it good

though I saw it all around
never thought I could be affected
thought that we'd be the last to go
it is so strange the way things turn

drove the night toward my home
the place that I was born, on the lakeside
as daylight broke, I saw the earth
the trees had burned down to the ground

don't give up
you still have us
don't give up
we don't need much of anything
don't give up
'cause somewhere there's a place
where we belong

rest your head
you worry too much
it's going to be alright
when times get rough
you can fall back on us
don't give up
please don't give up

'got to walk out of here
I can't take anymore
going to stand on that bridge
keep my eyes down below
whatever may come
and whatever may go
that river's flowing
that river's flowing

moved on to another town
tried hard to settle down
for every job, so many men
so many men no-one needs

don't give up
'cause you have friends
don't give up
you're not the only one
don't give up
no reason to be ashamed
don't give up
you still have us
don't give up now
we're proud of who you are
don't give up
you know it's never been easy
don't give up
'cause I believe there's the a place
there's a place where we belong

Though I am really down these days...

Friday, December 03, 2004

Serial COM in C


I've been studying C programming using the API to communicate with the
serial port using WINDOWS and the Microsoft C/C++ compiler. I am actually
implementing examples from Professor Constantino Seixas Filho, PHD from UFMG
and trying to put modularize everything.

Professor Constantino has a real interesting page with his lectures that can
be found at:


Warning: I tried to compile it under BCC55 and DevC++/MingC and it won't work.
It happens because the code uses MS Typedefs, and the other compilers won't find
these references to the API structures and constants.

Although I can help you to learn it, I am not saying that I am the author of
this code. I rather just modified it a bit.

I just plan to create a framework to communicate a PC with a microcrontroller,
maybe a PIC or HC12.

If you would like to read the code, please visit my web site. It is clear that this API isn't much harder to grasp than the Java one. However, it apparently runs ok only on VC6.

Monday, November 29, 2004

C on Motorola HC12

I found out this web site:


Professor Valdano allows his book for ICC12/ICC11 C Compilers for Motorola HC11 and HC12. ICC is just shareware, so after 45 days I am over. But I just suppose it is compatible with Metrowerks or Cosmic.

In a 8012.h file I declare:

#define PORTA *(unsigned char volatile *)(0x0000)
#define DDRA *(unsigned char volatile *)(0x0002)

And In a Main.c file I write:

#include "8012.h"

void JustInit( unsigned char a , unsigned char b ){
DDRA = a;
PORTA = b;
void main() {

And then, you get PORTA intialized and a value is passed to it. Note that it is only necessary to use a macro to map the memory address of the port to a variable. The DDRA register sets PORTA data flow direction whereas PORTA sets the byte data flow.

Horrors and terror, hay?

I can figure out that to access SCI registers is a matter of doing similar mappings and treating them. With C , it becomes an easier task compared to ASM.

It was late at night

Sundays are the most boring annoying days because you're always thinking about Monday. Heh.

I always watch E.R on Warner Channel and they have a new show that's aired before E.R named Jack And Bobby. Man, it looks like a great one. But during a commercial, I saw an advertisement. Someone in an airplane was emailing. Well, this is the most concrete example of encapsulation I know. Because that guy does not care for TCP-IP or SMTP or how the hell his email would leave his notebook 10 Km above the sea. Wireless connections, satelytes do not come at his mind. It's just like you and I emailing using Thunderbird from home.

As more as I get deep at OOP I just think all the languages that support it are similar. As more as I think on low level program, I like pure C more and more.

Wednesday, November 24, 2004

Do you read this?

Good question. I hesitated a lot prior to start blogging because I am a nerd that likes to write his own XHTML code. But, I found out that Blogger just writes decent XHTML and W3C Compliant code. Blogging is an exercise of introspection, as you don't really know if you are read. As you see I keep referring to my favorite subjects:

- programming
- music
- films

Back in 1990 my father had a PC XT and I made a banner to a high school part . A friend of mine asked me if I could write a program to make it. I had to tell you him that it wasn't necessary. Personal Computers generally are for regular usage.

I actually don't mind that most people use it for simply using the internet, but I think it is a little strange for me that people want more and more easy solutions like that bizarre AOL interface.
When I first used internet back in 1995 everything was new and I felt like I was walking in a new ground. At that time I wondered how all those networks worked and now that I know it well I know for sure that there are a lot more to learn.

I am specially interested in microcontrollers: PIC and Motorola. Why? That's my job and I think embed systems is the coolest area of engineering as it includes eletronics, programming and many details. Basically, everyting can be defined in a loop:


If you close the LOOP you get a CLOSED LOOP control.

The user input must be converted to an electric signal and next to a digital value. We call this, analog to digital conversion. (CONTINUES...)

Programming PIC and simulating them (for people that can't afford)

No, you won't have to use warez. I am using several tools to program PIC in C and they are all free.

[BTW, I am the sort of person that although thinking that software prices are very expensive, I simply do not use warez tools]

First of all, get MPLAB from Microchip:


Next, get PICC Lite compiler. This is a freeware tool version of a commercial C compiler for PIC with restrictions. You can only program a few models, but for broken people like me it is enough.


Their documentation is pretty good although quite large and complex, but if you check this other fantastic web site, you will enjoy to notice that they have thousands of line codes to help you:


Next either you choose the standard MPLAB way of simulation, which won't allow real world applications or you please check the amazing freeware software designed by Nicolas Colombain named MicroDev:


With uDev you can add serial analysers, oscilloscopes, leds, displays, logic gates and a huge variety of interfaces. You simply design the circuit and next load the program HEX file to the uC and starts the simulation.

I find the Harvard archictetures a bit more easy and natural for embed systems as you will notice comparing 8051 or HCXX to PIC. PICs are also a little easier to program and to interface.

Tuesday, November 23, 2004

"The Apprentice" Brazil


I haven't missed an episode. For starters I thought it'd suck because my Roberto Justus initial and not accurate views of his of character and opinions, but I ended up respecting his views and choices and most of all, his business analysis. I actually am a rather technical guy, but I have been forced to think about marketing and business because a lot of interviews focus at this to select people.

However, I think business and marketing people could sell anything with a decent propaganda and for me this is what implies in a degradation of our society; we give value to sell rather than design. People want to make millions out of management and marketing and tons of Brazilians are millionaire due to it. However, what does matter for evolution and to make a more decent nation is science and technology. Not mono-culture of sugar cane, or producing steel, or selling orange juice. It is computer hardware, software, bioscience, electronics, strong history and human sciences guys and girls that do matter.

Today a new chapter of "The Apprentice".

Friday, November 19, 2004

two minutes to midnight

11:58 sounded in the clock when I started this.

Well, I saw Spider Man II. I think it was an awesome movie and I could not avoid to think about Joseph Campell and his sayings and theories about modern mythology. Spider Man II is simply as good as reading a Stan Lee plot with ink by Steve Ditko.

Man, the Firefox plug ins are so fucking great , I am obsessed with them :-)


Despite that, I have gathered lots of materials related to HC12 and HC08. I have solely programmed in C lately regarding uC and I am refreshing my Assembly for PIC and getting in touch with the Motorolas.

Wednesday, November 17, 2004

Mozilla Firefox 1.0


I have installed Firefox 1.0 and lots of their plug-ins. If you want to insist with IE, it is a real dumb decision :-). FireFox comes already with many security configurations and allows many plug-ins to be installed.


And the plug-ins:


Horrors and terrors, hay!

Automation and control systems


Control systems is the root of lots of scientific fields and technical disciplines. We can say it is divided in:

- classic control systems
- digital systems
- Discrete control
- Artificial Intelligence techs
- Instrumentation/Automation

Classic control systems and digital control are mainly restricted to academic means as they rely on a deep analysis of the problem. Discrete control does not rely on closed Loops, and we can say that PLCs, microcontrollers are the devices used here. AI techs also are mainly used in academic means, however you can see that most Robots these days use one of its fields. Instrumentation and automation is simply a pragmatic view of control systems: eliminate most of the math, make the physics of it standard. In this sense, the Automation and instrumentation engineer does not need to get in touch with the technology it self, he just uses tools like PLCs, network bridges and transmitters.

So automation and instrumentation engineers won't deal directly with microprocessors or A/D converters. It is not an easy task but it demands a lot of pratical work.

It helps if you are programming Allen Bradley or Siemens PLCs, because these guys are standard makers of PLCs and they allow a huge variety of devices.

Tuesday, November 16, 2004

C, Motorola, film and others


I received an special edition of CodeWarrior ( MetroWerks ) IDE and C compiler for Motorola's 68HC08 and 68HC012 microcontrollers. Up to a certain limitations they send this CD for free.
Also, you can request hardcopies of Motorola's books from Motorola. For free.


Take note, now Freescale is the Motorola's brand for semiconductors. If you asked me for a dream job would be at Motorola. They rock the world.

I am thinking to write a C tutorial in Portuguese, but dedicated to novice programmers. I think there are excellent books in this area, but none are free. I would enjoy to teach public school kids to program in C if my schedule allowed me. If more people knew C, this world would be better.

Films: I have seen:

- I Robot : Excellent thriller. Sci Fi at finnest. If you ever read Asimov's tales you will enjoy it a ton.
- Butterfly Effect: based on a Bradbury's tale, non linear dynamic systems scientists, aka chaos theory scientists create the term "butterfly effect". It is related to the fact that small effects might affect systems so that great outputs are created. For ex, if a butterfly flies its wings, it might move air particles so that it ends up with a new tornado. In dynamic systems, the
fly of the wings is the input and the ouput is the massive moving of the air particles. Operational amplifiers may be used to create oscilations if you use feedback. A simple 0 V input might create
an oscillation. Past events might affect future events. Through this premise, they did an excellent film.
-Shrek 2: Part one was ok, but this is one is so amazing and funny. It is funny and it is intelligent.
- I saw a Sean's Pen film with Jack Nickolson, whose title I can't remember, but it was excellent.
I am always surprised with directors that can deal with violence and do not make abusive films through it rather just showing how vile and violent the human race is.

Van Helsing sucks a lot. Bleargh.

I saw the "Threasure of Sierra Madre" DVD by John Huston for sale and could almost not resist.
Man, I love this film. If I was rich...

Should I be rich.....

I also know that there are many DVD versions of my favorite shows being sold in USA: Quantum Leap, Millennium, Babylon 5... Man....

I also know that the Visual C++ 2005 Beta is sold for 20 dollars and I don't have even 20 dollars.

Wednesday, November 03, 2004

"For a proper observer, it is only a matter of time..."

I am tempted again to study the WIN32 API programming in C. I have initiated the subject in my mind but didn't go further. Should I write a GUI program I perhaps would choose C# or Java. However, doing it in C sounds cooler. Even with all those bizarre typedefs that Mordor created for the API. I shall wait until the "longhorn" pops on the hill.

The Bloodshed C++ IDE comes already with some great samples programmed in C. They are so fast and well written that might inspire you too.

Toffolo, Alemao, "Cidade de Deus"..

When I worked for cutrale in 2000, a co-worker of mine, who was a process engineer, said that "Once you make a professional choice, you direct your whole life. Make a wrong decision and you will have to face it all life". It was a hot August Saturday and we were eating a "feijoada". Fast enough to go back to work.

This weekend, I had to replace one of the tyres of my car and I eventually had to buy a new one. I was visitting my parents at Botucatu and I always go for the Alemao store in these cases. Alemao is for sure the best tyre store and the best place to repair tyres and to do all the tyre related stuff. Major tyre chains can't rival with him. Alemao is probably rich, but he still helps his employees to replace tyres, although he might not smile, the guy treats everybody with the same respect. His store is not open just on Sunday afternoons. I don't think I know anyone with better service. Yeah, the prices are excellent too. His employees are the sort of people that tell you: I can help you to buy a cheaper tyre but that still works.

I saw "Cidade de Deus/City Of God". It was much better than I thought. I abhor the guy who wrote the book which was the basis for the film, but the film is great.

That said, I was thinking about some power metal songs which describe how to face your enemies, but I ended up just thinking about professional choices. Wrong choices. In your
job, not many people will be friends with you in fact. But many will pretend. Beware. This can
kill your carrier.

Sunday, October 31, 2004

Sorry for being absent...


I admit that I haven't posted much here lately. My job consumes me a lot these days.

I saw "Troy". I thought it'd suck, but I had many factors that would make me enjoy it:

- great actors (Brian Cox, Sean Bean, Brad Pitt (you gotta admit the guy is a great actor), etc )
- Wolfgan Petersen the director
- Excellent digital reconstruction
- The story took place more than 2000 years ago

Well, I was not disappointed.. I didn't watch it after the finnest art on Earth, it is just a simple fun. Of course,
some American films made to aim it may be horrible as well as pseudo-art films. As much as I miss
DVDs easy to rent and available from Spike Lee, Kieslowiski , Truffault, Coppolla or Martin Scorcese on the DVD store, I don't mind watching good and fun movies like "Troy". Sean Bean (Ulisses and also Boromir
on LoTR) and Brian Cox(Agamenon) steal the show!

Honestly speaking I like those "artistic directors" because I have fun watching their films.

In the technology field, I am basically getting my eletronics books again, digging C deeper (even more), reading PIC datasheets and tutorials and helping ZeRo with C++.

Monday, October 11, 2004

Queensryche "tribe"

A friend of mine cd-red me the new Marillion. I like it so much that I went out for buying it today just to find out that nobody had it for sale. I saw Queensryche "tribe" and bought it. I am fan since 1986, so I might be a little biased to say that I loved it. I only can't get why the booklet has no lyrics and horrible font to read the text..

Monday, October 04, 2004

Sunny Monday and Rainy Sunday

Yeah, even though it might sound weird that's what we got here. Thanks to God it has rained all weekend but the sun is back. I am not a gothic depressed fellow, it's just that the air level of moisture was around 5 % last week and the temperature went beyond 40 .o C. Well, I am again back to job searching.

There was an ellection for mayors and councillors this weekend and I just didn't vote. Well, I had to justify to be out of my area as I haven't transfered my ellection card or whatever this is named.
I met one of the candidates for mayor while my wife, son and I were driving this weekend. I said
I didn't vote, and he said, whatever, shake my hand! WOW.

Wednesday, September 29, 2004

state machines in C

In C++, state machines can use polymorphism, but C is not OOP so you might need another approach.

Tuesday, September 28, 2004

C and Dynamic Allocation


In C++, dynamic allocation is safer and easier to implement. In C things are not that easy or clear but they're more fun to program:

I was just playing a little with calloc functions and commented out the code enough so it explains it all well enough. I just used it with functions so that you can see where and how to use pratically dynamic allocation.

Check the code here...

It is easier to think about of it using abstraction at maximum, for example:

calloc( a , sizeof(int) ) will return a pointer to allocate enough memory for an array
of size a rather than trying to see those diagrams where the memory points to this and that.
Ok, after you getting this go ahead and try to grasp and grok those diagrams, but prior to it
you will know what it does...

Monday, September 27, 2004

C: Functions that return pointers and function that return values of pointers

It might be a little simple if you're used to C, but it is not actually. Let's say:

  1. int Horrors( int * );
  2. int *Horrors2();
  3. int main(void) {
  4. int y = 5;
  5. int *ptrF = &y;
  6. Horrors( ptrF );
  7. int h = 5;
  8. Horrors( &h );
  9. *Horrors2();
  10. return 0;
  11. }

Line 1 declares a function that returns and integer value. Line 2 declares a variable that returns a pointer. Normally you'd return a pointer to a structure, so it makes sense to make a function that returns a pointer.

  1. int Horrors( int *a ){
  2. /*Returns the value of a pointer*/
  3. return *a;
  4. }
  5. int *Horrors2(void){
  6. /*Returns a pointer*/
  7. int a = 6;
  8. int *ptr = &a;
  9. return ptr;
  10. }

Not that line 4 returns the value of the variable a whereas line 10 returns a pointer to a.

Wednesday, September 22, 2004

I give up


I gave up of this graphic library. I just don't feel too motivated to go further. I am researching for C programming for PIC , 8051 microcontrollers now...

My both arms still hurt and now my tooth is also. I am not sure it is named in English, but it is the Sisus tooth.. The last one..

Tuesday, September 21, 2004

How the graphic library code is


I thought I could avoid typedefs hehehe But I didn't get it..

Note that I had to implement a fake geninterrupt() as I am trying to get a similar one to run here.

Full code at here.



I was just for fun commenting C code using XML tags and wow, I didn't know it, but it looks like my browser parses it and does not display my tags as text or HMTL.

For example:


You should not see anything above if it worked. If not, something like:

[Horrors And Terrors] HORRORS[/Horrors And Terrors]

Should appear. Maybe the blogspot server parses the XML tags...

Let's us see..

A few seconds later...

YEAH the whole thing is parsed! You may find it me ignorant but I didn't know that really!

More code


I was looking after an Assembly routine to write a pixel inthe screen when I found this article. Despite a little old, it presents a logical sequence to accomplish the task. However, as it was written back in 1994, I suppose the author didn't use DevShed C++ to program it, so the function where he access the interrupts of the video card simply does not work ;-) As I say in a comment below, I am going to use my FREE and OLD C compilers IDEs : How to put a pixel in the screen by Mr. Grant Smith .

This whole code relies on a function, that does not work on WINDOWS, so let's find it or implement it ! :-)

I have added the code supplied above.

C /Assembly code for graphical pixel

I was checking the web yesterday when I found this excellent article:


It basically teachs you to program a routine to write a pixel to the screen. I will try to dig it deeper.

In the meantime, I just will search for writting a pixel on MSDN.

Monday, September 20, 2004

More on a graphical library

I've been working on a simple graphical library and I have more of it now. It has to get much better though. I am not using typedefs or Macros as I am trying to make it clear to the user. I am currently converting some parameters to use the structure point..

During the weekend

Besides playing a little with C# on WIN98, I actually spent time with my son and wife. I also listened to lots of great music, part of it had my son with me. Bozzio Levin And Stevens, Jethro Tull, Tempest, Van Hallen, Sophistree, Peter Gabriel, Aghora and a few more.

It looks like my 1 year and eightmonths son, digs rock and roll! WOW...


Besides, I watched an excellent film, which was "25th Hour" by Spike Lee. Man, I really enjoyed the films I saw by Spike, but this one ranks with "Jungle Fever". Also, the soundtrack by Mr. Terence Blanchard is superb. I recommend this 2002 movie and I am not sure why most of Spike's films are absent in the video/DVD renting stores. Also, saw a "Circ D'Soleil" film on HBO, which rocks like hell. I am not a big Circus fan, basically because I find putting animals to make funny things too stupid. But "Circ D'Soleil" does not have animals besides humans. I think I enjoy it more because of the live music or because those artists are really great at their jobs.

On Friday I saw the last "Carga Pesada" episode. It is a Brazilian TVSHOW. In the 70s/80s they were a popular series here and there's a 2003/2004 season going on TV. But it was cancelled because they want that "The City of God" crew new series to replace it. I find it too sad, because "Carga Pesada" in both eras, is one of my favorite series. Two truck drivers travel through the Brazilian country and find lots of good stories to interact. It has two of the best actors in Brazil, named Stenio Garcia and Antonio Fagundes and plots that go beyond the regular and average Brazilian scripts.

More of Mordor

It is fun that I call Microsoft "Mordor" because I actually like some of their software, basically:

Word, Excel, Visual C++ and C# and I might add WIN2000 too.


Anyways, Mordor says about .NET:

System Requirements

  • Supported Operating Systems: Windows 2000, Windows Server 2003, Windows XP

Terrified WIN98 home user like me? Yeah, if you don't plan to run .NET pages, .NET runs OK. I can't say what does run and what not. The article where I learned how to do it (which is plain simple) was written in 2000, and I am not sure whether the author updated it.

As I already mentioned, I installed the new version of Sharp Develop
and it runs perfectly on WINDOWS 98 and it's more stable than the other versions I have used.

My home set is a AMDk7 1.2GHz on a Soyu motherboard, 32Mbytes of Video memory, 128Mbytes of RAM. I actually only need an upgrade on RAM memory but for programmers like me, super mega ultra processors won't make difference. I am from a time, I had to run Delphi image processing algorithms on P1 or 486 and a machine that had 256 Mbytes of RAM was unique.

Blind .NET and Microsoft users will argue that it is an heresy to install .NET on WIN98. They will also point out that I am wasting time not focusing on web programming. I actually don't care. Asked to do web programming I'd rather use JSP/Servlets or I would try to learn PHP (with pleasure) rather than using .NET. Although I do enjoy C#.

"Horrors and terrors", should I quote a friend of mine...

Sunday, September 19, 2004


I will have more of this later, including the official thoughts from Mordor, er, microsoft. However, I could compile and run C# code on Win98! Probably ASP.NET won´t work as it relies on IIS. I have to check whether ADO.NET will ork also. But now you can program C# on WIN98 , but the funny aspect is that always could do it..

The article I previously mentioned here explains it all. It is not hard, open the installing .NET file with WINZIP or WINRAR. Next, just unzip the files and run the exe install.exe. Prior to it, be sure to have installed that msi installer .

I am running sharpdevelop right now and btw, the new version is considerably much better and stable...

Friday, September 17, 2004

Simple Events

If you haven't read the previous post, I hope you read it first.

The way C# Handles events is very clear. You first instantiate the component:

this.button1 = new System.Windows.Forms.Button();

Next, add it to the container. In this case I just add it to a groupBox component. I will have to add the groupBox to the Form of course. Actually, by using C# Builder this is all done automatically :-)

This code below sets the button properties and the last line is the one that matters:

this.button1.Location = new System.Drawing.Point(152, 16);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "Calculate";
this.button1.Click += new System.EventHandler(this.button1_Click);

By doing it, the compiler knows that you created an Event to the component. The Click event is the one in this case.

With Java, you would have a real complicated task for adding a handler, by either using an inner class or creating a separate class. With C# it gets easy:

private void button1_Click(object sender, System.EventArgs e)
this.label1.Text = this.textBox1.Text;

The System.EventHandler( ) class recieves as parameter the method implemented above. It simply passes the value in a textfield to a label whenever you click the button. If you know me, this the program I always to when learning GUI programming for a certain language. :-)

The code that is automatically created when you start an application with C#

When you launch C# Builder you get an automatic code just exactly any Borland RAD tools like J Builder. However, their code is simply optmized. I just launched it and want to comment the code, this will help me and perhaps you to get it:

First, these imports make a call for the proper classes:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

The solution is to put your project in a namespace, rather than naming it after the class name. MS and SUN do it because they think applications lie in the web so that it is possible that two applications have the same name.

Note the comments using /// and XML code, I didn't know this was possible, but it makes sense. I usually document my codes using XML, in hope that an ALIEN in the future parses my code :-)

namespace Gui_Sharp
/// Summary description for WinForm.

public class WinForm : System.Windows.Forms.Form
/// Required designer variable.

private System.ComponentModel.Container components = null;

WinForm is derived from the class Form, which is basically the typical way of doing it
in MFC or Swing, you have a top container and derives it.

It looks like that you may free memory from unused components with the the last line.

public WinForm()
// Required for Windows Form Designer support

// TODO: Add any constructor code after InitializeComponent call

It is cool to initialize most components on a method not in a constructor, as it will become a huge mess, when you start drag and dropping components over your form...

/// Clean up any resources being used.

protected override void Dispose (bool disposing)
if (disposing)
if (components != null)

This code will released memory after the programming is closed.

#region Windows Form Designer generated code
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.

private void InitializeComponent()
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "WinForm";

this points to the current class/object which is the form. With it you may set its properties.

/// The main entry point for the application.

static void Main()
Application.Run(new WinForm());

You need an static method to run the form as an application.

If you ever want to code using notepad cut this code and paste it. if Borland does it that way there's a possibility of being the best way of initializing a basic and simple form.

With C# you can create an executable, so despite performance issues, C# is much better than MFC ...

Lazy bastard I am ;-)

Thursday, September 16, 2004

C# on WIN98 and NT

This article claims that it is possible to install .NET on those two operational systems. I haven't tried it yet, but it looks possible. This strategy is related to the fact that MS does not want to give support to WIN98, forcing users to upgrade. The JVM runs on WIN98 and NT so it is not make sense not allowing that C# runs on Windows 98. Maybe all that web programming crap named ASP.NET does not work well, but who cares?


It stands for Graphic User Interfaces. When Windows was first released in 1985, C was the main programming language and C++ was a new tool. Although OOP was an old concept, for Windows and Microsoft C was the "lingua franca". So, the WIN32S API was conceived as a layer sitting at the top of DOS and Screen controllers boards.

Maybe there was a low level C code to write a pixel to the screen, by using an Assembly routine that lighted on the particular pixel with a particular color. Suppose this can be encapsulated in a simple routine :

void itWillLightAColorOnTheScreen( struct color c , int* x , int* y );

How could this function be implemented? The processor sends a signal to the screen board, we will name it a message. "Hey dear board, check if the pixel is on or off. If not, light on a pixel there with this color." Next, pulses are sent, the microprocessor at the screen board recieves the message (acknowledge it) and puts it in its stack of tasks. Next responds "Dear microprocessor, now I can put that pixel on the screen!". Next it will try and when it gets it responds "I got it bro!". So we have a pixel in the screen. I have no clues of how many lines of Assembly code this would require (I can check at my book at home if you need ;-)) , but assuming WIN32S coders arguments would make us thinking that "true coders" would only write GUIs in Assembly, as it sits at the top of the C WIN32S layer.

Well, let's assume we have that particular function. A code to write a simple line goes below:


struct color {
char* colorname;
int colornumber;

void itWillLightAColorOnTheScreen( struct color c , int* x , int* y );

int main() {
struct color c;
int i = 0;
int j = 0;
int InitX = 234;
int InitY = 234;
int FinalX = 500;
int FinalY = 500;
c.colorname = "Blue";
c.colornumber = 234;/*234 is a number picked up randomly ;-)*/
/*Now we are going to create a line*/
for ( i = InitX ; i < FinalY ; i++ ) {
for ( j = InitY ; j < FinalY ; j++ ) {
itWillLightAColorOnTheScreen( c , &i , &j );
return 0;

void itWillLightAColorOnTheScreen( struct color c , int* x , int* y ){
/*Do the thing*/
printf("Good man, I have written that color to the screen!");

Now, how do I create a window? Write four lines and connect them. Easy ? Maybe. Next, one should write code to map the serial port where we have a serial mouse. This mouse simply sends a signal to the processor to indicate where the user would enjoy to place the mouse in the screen. Or:

Input( Xuser, Yuser)------> function that maps these coords to the screen and informs the

If the user presses the button, we assume its state changes to "1", so that the processor might consider that the user wants to launch an event. Next the program should associate the event to the graphical representation and launch the desired event. Thus, it is huge and complex task when we add mulithreading issues, or, the processor simply has lots of other things to handle.

Suppose a programmer shoudl rely on Assembly code and low level design, one would take decades to create a simple program. So the C WIN32S API comes at hand. But then, it is also very complex and it generates large code.

Well, Microsoft encapsulated it in a library, an OOP library named MFC. Microsoft Foundation Classes, which puts WIN32S code (structs, functions, properties, macros) into the OOP standard, so that C++ can come and make it simpler to read. But then, MFC sits at the top of the WIN32S layer and frankly man, it still has some bizarre things like resources , macros and typedefs.

If you want to dig deeper how to create OOP code from C code, I recommend this site:


SUN just encapsulates the WIN32S API in an API named Swing, which is an OOP library. However, it loses in terms of performance. However, it is an excellent enviroment for GUI. I can say the same for the other OOP APIs I know, that are Python's Thinker and C# graphic APIs. However they sit at the top of the WIN32S and that low level Assembly code I mentioned.

As an Engineer, I find the solutions that are easy for me and have better results. So, I don't feel like knowing WIN32S or MFC. Charles Petzold, who's known as the WIN32S GUI guru simply says "I prefer C# APIs". Who Am I to disagree? For microcontroller tasks, non GUI and fast calculations C is still the top one. But come on dude, C for GUI development is too much :-) I like RAD tools, especially Borland ones like C# Builder or J Builder. But coding at hand it is funnier. But slower than doing it via RAD ways.

Wednesday, September 15, 2004

C# Builder Personal

I have installed the C# Builder software personal edition from Borland. It looks more stable than Sharp Develop .

However, you should not use C#Builder for commerical applications.


Monday, September 13, 2004


Why do I like C# and I am not that fond of .NET?

It is hard to say. I love the C# Syntax. It's even cooler than Java (although I prefer Java because of its libraries and APIs) because it has C++ features that we enjoy. You can create exe files. But I am not probably doing web programming with C#, neither would rely on the XML technology to create web services. I abhor VB.NET and ASP.NET programming, not because it is hard or easy, just I like desktop programming better than web programming, and as I am not paid to program in C# I do choose what I like best :-)

Despite of what anyone else says, I will use C# as a tool for math, plotting graphics and maybe windows sockets.

Thursday, September 09, 2004

As everybody knows ...

The Genesis probe crashed.... :-(

At least those probes in Mars are running Java, heh ;-)

Visual C++ 2005 Beta


Can you believe? I knew it from an Orkut C++ community: Microsoft is distributting Visual C++ 2005 Beta for free, yeah, free! I could not download it yet, I am not sure if that's due to security reasons (with MS the coolest downloads just go in that background way, so you can't download a file and install later) or due to lots of people trying the same. You can get the CD of course, 20 dollars. Microsoft Brasil does not distributte it, so they told me.

I once read an article that pointed that the Visual C++ guys at MS are not totally .NET dudes, so I am not surprised that Visual C++ is one of their best softwares ( with Word and Excel ).

I am actually totally fond of C#, not for XML, yadda yadda web services, ADO.NET, just simple and plain code and GUI. I am not totally happy with .NET but C# rocks...

Wednesday, September 08, 2004

"Golden Apples Of The Sun"

In 2001, the Genesis (cool name huh?) was sent to grab particles of the SUN. If you ever read "Golden Apples Of The Sun", by Bradbury, you will enjoy this more than anyone besides particle physics researchers.

As of today, September 8th, the probe is coming back to earth bringing together particles of the Sun...

Sunday, September 05, 2004

Python x Java

I am not really trying to analyse it deeper, just put random thoughts regarding what I have felt about these two languages.

Python does not require that you declare data types, although requires that you initialize it. As I am used to declare any variable, I had to change a little bit to enjoy the Python way. I did like the numarray package, as it provides lots of functions for manipulating arrays. For engineering purposes, having a strong array library is very important.

The numarray API already overloads operators like +, * and math operations, which is also great. If we see this way, Python is perfect for science. OOP programming in Python is easy, although I saw no references yet to the use of polymorphism in the same way we can do in Java or C++. For ex:

Foo * f = new Foo( );
Foo *f2;

Foo f = new Foo( );
Foo f2;

In either languages if you do f = f2, you make the pointers to reference the same objects. Also, if you have a function that accepts objects with an heritage hierarchy, the compiler knows at run time which object you're passing. Suppose for example, you have a class that represents a virtual world. And you have zillions of beings that are derived from a base class. Without polymorphism, If you were to implement a method that used any of these beings as parameters you would end up with an implementation for each. With polymorphism, this is not required. Suppose you have: Being->Warrior->Wizard->Preacher->Worker and any of these have a function named boolean Eat( ). Suppose in your code, there's an specific event where you need to pass an object and inside this method you make use of the Eat( ) function. Your implementation would be simple:

void IWilluseThatFunction( Being b){
if ( b.Eat( ) ) {
//.. do this
else {
//do that


I actually don't mind if Python does not allow it. I have implemented several simple non OOP functions in Python (simple enough, that everybody might have done it too) and it is too clear and direct. Suppose I would require a library with functions Jaca1, Jaca2...Jacan. In the OOP way, I would require an instantion of a class with the proper parameters and then I could make use of the functions. The non OOP way simple allows that I call every function passing the proper parameters. If I am just trying to get results from a data and I will not use them in another block of code, I'd not use OOP.

#OOP way
JacaObject = Jaca(HereIPassAXMLFileForEx)
#now I will have to access its methods
JacaObject.Jaca1( );

#Non OOP
from JacaCollectionOfFunctions import *


I did like the Tkinter GUI library that Python has built in. I found it faster than Swing. And both Swing and Tkinter make use of a similar OOP model.

Perhaps tempted, I would say that I still enjoy Java better, but Python comes close.

NP: DIO "Magica", excellent metal album!

Saturday, September 04, 2004

It is not an easy world


Everybody has  have seen the massacre in Russia. There are no acts that justify the killing of innocent. Not even killing more innocent children. We know that the Russian government has acted in same vile ways to the Tchechenian people but nobody will judge their actions legit  movements to save their nation now. Instead, they are now, just another group of terrorists, that do not want anything else besides causing sadness and horror to achieve their goals.

I would not be surprised if the Russian government responded it with more force.

In the meantime, in Brazil, drug dealers, robbers and kidnappers are doing their job. Politicians still take away money from the fees. Our president lies in his own castle of illusion and leaves the country to his colleagues  just allowing them to implement bizarre actions that evoke socialism mixed with neo-capitalism.

Nobody gives the proper importance to technology. They plant sugar cane and sell it abroad. This is our curse, or has been our curse since 1500, plant and sell sugar. We make the cakes and pies all around the world but we destroy our natural resources. We drive cars with alcohol-based engines but the nature is getting dry. The town I live is the ultimate example: the biggest sugar cane production from this world comes from Sertaozinho-SP and the weather and the nature there, practically look like like a desert. A sugar cane desert....

A moment of silence for this world and for the children that died in Russia...

Thursday, September 02, 2004

More of DIO

I have listened to "Inferno: Last In Live" and "Magica".

The first one: Excellent live album full of favorite songs of mine. My son and I actually headbanged to "Long Live Rock And Roll" before his bath. The kid is only 1 year and 7 months but has a future :-) !

"Magica" is another excellent album, with a good story and Craig Goldy performs pretty well.
It is great to see Simon Wright (former AC/DC drummer ) playing with DIO. The original DIO bassist also plays at "Magica".

btw, Steve Vai at Orkut, added me in his friend's list. Although I am not sure that's Vai, I am finding that it is possible to be...

My friend Chang and his wife Yi Wei are coming home tonight. They will cook Chinese "pasteis" and my wife will cook "canjiquinha". I think this is gonna rock. Yeah, my wife and I will have to forget the diet for at least today...

Music Advice: Steve Vai "Sex And Religion", my favorite Vai.

Wednesday, September 01, 2004

Listen to Dio

DIO rocks...

I have bought two cds a few hours ago, I am listening to them at the job, so it is not an accurate listening...

Anyway, the sound of "Magica" evokes the 80s metal that Dio was one of the most import artists.
Singer with no equal in metal, always was a great composer and song writter...

I have "Holy Diver" on LP for nearly 20 years and it still impresses me. This is actually one of my magic albums. I am not thinking much about complexity, just good riffs and excellent vocal melodies and a real decent story. You hardly get that from these new melodic and power metal bands, but with Dio, you get the finnest metal art...

I liked the Craig Goldy riffs. Just like Vivian Campell and most guys that played guitars for Ozzy in the 80s, they have a similar sound, but quite cool. You know those inversions, playing 3 notes chords keeping the root the same, just playing it open..

Man, I miss the 80s. The music at that time was better, even the pop music.

NP Dio Magica

Tuesday, August 31, 2004


Guys like me suck completely at graphical design, so I did like this template that they've allowed me to use here.. thanks...

Windows X Linux and more...


Even though I agree that being a Linux user is much more cool to a geek like me (I really love when someone calls me geek), I hardly get time to use it. Although, it makes no difference because I hardly touch network and system administration tools. I prefer Linux but use Windows...

I agree that the best C++ IDE is Visual Studio, although I think I'd enjoy the full version of CBuilder X. I liked the free version, but no RAD tools. I know just the basics of MFC. I know the SWING API pretty well, so I prefer OOP GUI libraries and I am lazy to do a lot of typing using the WIN32S APIs. Even guys like Charles Petzold prefer C# GUI library, so why would you bother to insist with the old C libraries?

Speaking of it, I was trying the Tkinter library and the first example was really fast that impressed me. I'd not use RAD tools except for complex tasks and the programming model that Tkinter makes use is similar to Java Swing. Sometimes I become too confused when I try to think what's happening in the background, lots of C code going around, lots of threads. But for guys like me that didn't go for Computer Science at college (I wish), it is easier to encapsulate the complexity. I think if ones does a good job designing an API like SWING of tkinter, it saves lots of time and allows the user to focus on programming.

That's all.

Music advice: Cynic "Focus". Technical Jazz Death Metal.

I have enjoyed this a ton


I enjoyed this blog a lot. I used to have my own blog on HTML, and I later gave up and started a blog. In Portuguese. Why do I write in english right now? Because it's fun. Actually, I chose English because I have my own website in Portuguese, so I found it cool to try a different language.

My former blog hoster had troubles to display an editor just like this I am using now. I use Mozilla and the only time I was forced to switch to IEs was when I needed some format. And I strongly prefer Mozilla to IE, I just moved off.

I hate the city I am forced to live as well as my job.

I have fun when I see my kid and wife, family, friends or watch a film or program anything.

My wife and I are trying to lose weight and it is painfull, but worth the suffering.

Let me try some python now...