Sunday, December 28, 2008

Hmm

Blogging takes too much time away from CoD5..

Friday, November 28, 2008

Powerbuilder byte datatype

One of the more frustrating problems with programming with windows api in powerbuilder is the lack of the byte datatype. Although as of powerbuilder 10.5 and up it is now included, those of us stuck with a version below that have to work a little harder to get the same results. This is how I was able to work around this..

char is the smallest datatype that powerbuilder handles and it is two bytes long. So, when ever the need for defining a byte array rises you would have to cut the size in half when defining the char array. For example..if funtion calls for a byte array byte[6], you would declare: char lc_char[3].

Now the hard part..say for this byte array the function is expexting the following:
byte[1] = 192
byte[2] = 00

byte[3] = 00
byte[4] = 70

byte[5] = 192
byte[6] = 70

Now, lets take the first two bytes to powerbuilder:
lc_char[1] = char(192)

This works as expected..lets set the next two bytes
lc_char[2] = char(70)

This is where things get tricky..how does powerbuilder decide which byte is filled with 00 and which byte is filled with 70? Short answer Endianness. Powerbuilder uses Little-endian store bytes in memory. We got lucky with the first one, it stored the number we wanted in the right spot. But if we leave it how we have it right now this is the result we would get:
byte[1] = 192
byte[2] = 00
byte[3] = 70
byte[4] = 00

Which is out of order. The easiest way to fix this is with a calculator. Since we now know that the bytes are stored backwards all we have to do is find the equivalent of 70 backwards. To do this we convert 70 to the hex equivalent(easily done with windows calc. just change the view to scientific then type the number you want to convert click the hex option): h46. So, we have h00 h46. Flip to get h46 h00. back to calc starting in hex mode type "4600", then hit dec. h4600 = 17920.

So, back to our char array. if we want to set the third and fourth byte to 00 70, we do this:
lc_char[2] = char(17920)

Now were in business. A quick example of the last two bytes in the array:
what we want: 192 70
Convert to hex: C0 46
Reverse: 46 C0
Convert to dec: 18112

lc_char[3] = char(18112)

Fun stuff.

Saturday, September 20, 2008

Matrix Show


I made (attempted to make) a cool screen saver check it out here: Google Code

Friday, September 19, 2008

Powerbuilder Datawindow.NET to DataSet

Converting from powerbuilders datawindow to a dataset in c# was a lot easier than I first thought..though i did write an entire function that looped through the rows to do it at first. I eventually figured out this short code here.

DataSet lds = new DataSet();
lds.ReadXml(new System.IO.StringReader(YourDataWindow.Describe("Datawindow.Data.XML")));


Thats it..(Make sure you retrieve first of course)

Friday, September 5, 2008

Sending Groupwise HTML Email

Wth. This weres impossible to find! Hardly any documentation about sending a simple HTML email with the Groupwise API. This is the ugly solution I happend upon when looking for a solution to a different problem.. (Assuming you've figured out the basics of just sending an email)

Create a file named "Text.htm" filled with the html message you want to send. Attach it to the email. Send it. As long as you dont set BodyText.RTF / BodyText.PlainText, the email will show the HTML by default when opened in groupwise.

My problem was solved with this, although it only works for groupwise clients. (All i needed) If you want to send HTML email outside of groupwise, I can only point you in the direction you need as I havent figured out myself. You would need another attachment named "Mime.822" which would be your header information for the email.

Note: Be mindful of the case in the file names.

Tuesday, August 26, 2008

So..this r a blog

I may start to use cause I r bored with life.