Pages

Tuesday, August 23, 2005

GreekEuroVerbalizer

Reading a recent post in dotNetZone.gr I decided to implement as a proof-of-concept an algorithm using regular expressions to convert a decimal numeral representing an amount of money, to a verbal from in Greek text.

So to make it more obvious the problem was to convert 1,234,567.89 Euros to the string "One Million, Two Hundred Thirty Four, Five Hundred Sixtyseven Euros and Eightynine Cents" (only that the text should be in Greek and not English as I typed here to make the concept clear for everyone).

The algorithm I came up with is not the best that I could do but is enough as a proof of concept. Do not be alarmed if it seems too long at first glance. It's just the code comments that make it so long.

Here it goes:
You can also find this at the relevant blog article in dotNetZone.gr here (in Greek).

Saturday, August 6, 2005

MetaBlogAPI for CS 1.1


I wanted to test w.Bloggar and BlogJet today for posting in a CS 1.1 blog. MetaBlogAPI comes as a separate download from CS 1.1 so I tried to find and get it. Believe me I had a real hard time!

After an hour or so of googling around for it, a friend from dotnetzone.gr finally pointed me to it.

Here it is:
http://www.telligentsystems.com/Solutions/license.aspx?File=cs_1.1_metablog

If you need it, go get it…

The other versions found in various posts in communityserver.org/forums are usually older versions and will just give you a "Method not found: System.Collections.ArrayList COmmunityServer.Blogs.Components.Weblogs.GetWebLogs(CommunityServer.ComponentsUser,  Boolean, Boolean, Boolean). (EGetRecentError)" error message.

I wish they had a more standard place for it on the web than just a form post…

Friday, August 5, 2005

CS default language problems

I run into an issue today regarding Community Server 1.1 (CS 1.1).
I changed the default language in communityServer.config from en-US to el-GR, only to get a runtime error.

The change:

<Core defaultLanguage="el-GR">

The error:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.

Source Error:
Line 49: message = FindControl("Message") as Literal;
Line 50: if(message != null)

Line 51: message.Text = string.Format(ResourceManager.GetString("DisplayUserWelcome_AlternateUserWelcome"), CSContext.Current.SiteSettings.SiteName);

Source File: C:\Documents and Settings\rousso\My Documents\Visual Studio Projects\CS\1.1\50615src\src\Controls\User\AnonymousUserControl.cs    Line: 51

Stack Trace:

[FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.] System.Text.StringBuilder.AppendFormat(IFormatProvider provider, String format, Object[] args) +1232

System.String.Format(IFormatProvider provider, String format, Object[] args) +65
System.String.Format(String format, Object arg0) +47
CommunityServer.Controls.AnonymousUserControl.AttachChildControls() 
CommunityServer.Controls.TemplatedWebControl.CreateChildControls() 
System.Web.UI.Control.EnsureChildControls() +100
...
System.Web.UI.Control.PreRenderRecursiveInternal() +125
System.Web.UI.Page.ProcessRequestMain() +1499


After meddling around a a little bit I pin pointed the problem to a translation error.

I turns out that the Greek language resource files located in /Languages/el-GR/Resources.xml were not properly (if at all) converted to reflect changes in code between version 1.0 and 1.1 of CS.

This line was the problem:
<resource name="DisplayUserWelcome_AlternateUserWelcome">Καλώς ορίσατε στο {0} {1}resource>

There, two String.Format arguments are obviously expected. On the other hand, line 51 of AnonymousUserControl.cs, only passes one (see source error above).

Removing the second placeholder from the format string solves the problem:
<resource name="DisplayUserWelcome_AlternateUserWelcome">Καλώς ορίσατε στο {0}resource>
The same stands for fr-FR (French) language resources I checked. Probably for others too.

If you can read Greek see my relevant posts in dotnetzone.gr. Also if you are looking to solve the same problem for the Greek (Hellenic) language see these posts in dotnetzone.gr where you can get the corrected translation for Greek text and buttons (it is attached to the post).

Tuesday, July 19, 2005

JavaScript - The World's Most Misunderstood Programming Language


Incredible article on Javascript!

I have been programming Object Oriented languages for a very long time (since OO Turbo-Pascal in late 80’s). The truth is that I myself had probably misunderstood JavaScript. Why? Two sets of reasons: a) all those reasons described in the article mentioned bellow, b) as a result of a I devoted no time in studying it.

Well, better late than never: From now on I am going to think twice when I need a piece of functionality on the client.

Do read this article by Douglas Crockford:

JavaScript - The World's Most Misunderstood Programming Language

P.S. Don’t miss in the article above the link to the code for inheritance in JavaScript. I am not going thought the cons of JavaScript here but in the pros compare it to inheritance models supported by C# and Java.

BTW: What do you think of multiple inheritance. We used to be able to use it in the C++ days (C++ is still around but anyway). Do you miss it in C# or Java? (I mean multiple inheritance of classes not interfaces i.e. class c inherits class a and class b. In C# and Java you can inherit form max one class and implement as many interfaces as required. But of course interfaces do not include base implementations…).

Also: Can you give me your best example where you really missed multiple inheritance?

Thursday, July 14, 2005

VS.NET Copy Project

Here is a solution for an issue I run into today.
Issue:
In VS.NET 2003 I tried to use the "Copy Project" feature to copy (deploy) the files required to run a web application to another web server. Nevertheless I got an error saying (more or less): ..."error occurred while copying the project" ... "Visual Studio .NET has detected that the specified Web server is not running ASP.NET version 1.1. You will be unable to run ASP.NET Web applications or services".
Context:
I was evaluating Community Server 1.1 and I had a full source installation on my Windows XP workstation altering bits and pieces to customize the application. I had previously installed a binary installation of the same product to my Windows 2003 Web Server.
Reactions:
First I made sure ASP.NET was running on my remote web server. Just to be on the safe side I even run aspnet_regiis -i, but it did not fix the problem. I had never encountered an issue like that so I googled for it. I found similar problems but all had solutions I had already tried with no luck. So mine had to be different.
Solution:
I figured out what was wrong when I tried to find out what my VS.NET was doing on my workstation to determine the ASP.NET version on my remote web server. It turned out that VS.NET did an HTTP request to:
http://MyRemoteWebSrver/MyApplication/get_aspx_ver.aspx
This file (an actual ASPX page named get_aspx_ver.aspx) does not exist so the server returns the well known "resource not found" error page. But ASP.NET in that default error page, returns the .NET Framework version information which is in turn used by VS.NET to verify version information. Silly but true!
Now! The problem was that Community Server by default had defined Custom Error Pages. So suddenly it occurred to me and here is what I did to solve the problem:
I went to my remote web server, and added the following lines to the web.config of my application:
Solved!
P.S: I also added the same lines to the web.config in my workstation since I was about to overwrite the web.config on the server. Remember I was originally trying to copy the files needed to run the project from my workstation to the web server using Copy Project feature of VS.NET.

Tuesday, June 14, 2005

CSS cache

One annoying thing about modifying themes and styles sometimes, is CSS caching. Although including a stylesheet in a page by using <link rel... tag is a good thing (because the stylesheet gets cached by the browser and is not downloaded again and again for all pages sharing the same stylesheets), this exact feature can become a bugger when you try to modify the CSS and instantly view the changes in the refreshed page.

I last encountered this problem when I was trying to modify this blog's theme by editing CSS files.

To overcome this problem I kept renaming the CSS file each time i made a modification to it by appending a version number on its name (i.e. base_1.css, and then base_2.css and so on).

This forced my browser to reload the new file.

If you have a better idea please share it with me.