[Openroad-users] Convert numbers to Roman

Bodo Bergmann Bodo.Bergmann at ingres.com
Thu Jul 3 03:26:14 EST 2008


Yes, this and/or making examples available on the community wiki is a
good idea.
Over the years I have written loads of them (so have others), and I'm
absolutely willing to share.
 
Bodo.
 

Bodo Bergmann | Sr. Software Engineer | Bodo.Bergmann at ingres.com
<mailto:Bodo.Bergmann at ingres.com>  | Ingres Germany GmbH | Ohmstr. 12 |
63225 Langen | GERMANY | +49 6103 9881 0


________________________________

From: Durwin Wright 
Sent: Wednesday, July 02, 2008 7:05 PM
To: Bodo Bergmann
Cc: International OpenROAD Users
Subject: RE: [Openroad-users] Convert numbers to Roman



Should we start thinking about capturing some of these examples,
partiularly the ones that are procedures, and encapsulating them into a
community-based application library?  I have seen some very good things
that you and others have done.  It would be really cool to make those
avaialble to others and allow people to add to them.

 

Durwin Wright | Sr. Architect | Durwin.Wright at ingres.com
<mailto:Durwin.Wright at ingres.com>  | Ingres | 500 Arguello Street |
Suite 200 | Redwood City | CA | 94063 | USA
<http://maps.google.com/maps?q=500+arguello+street,+94063&ll=37.487297,-
122.233200&spn=0.004602,0.012771&t=k&hl=en>   +1 650-587-5523 | fax: +1
650-587-5550 | "Wag the Dog" 

________________________________

From: openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] On Behalf Of Bodo
Bergmann
Sent: Wednesday, July 02, 2008 4:51 AM
To: International OpenROAD Users
Subject: Re: [Openroad-users] Convert numbers to Roman

 

Have you tried something like this (modiefied from some VB example I
found - should work for numbers<4000):

 

PROCEDURE int2roman(iNumber=INTEGER NOT NULL)=
DECLARE
    sNumeral=VARCHAR(4) NOT NULL;
ENDDECLARE
{
    WHILE (iNumber > 0) DO
        IF iNumber >= 1000 THEN 
            sNumeral = sNumeral + 'M'; 
            iNumber = iNumber - 1000;
        ELSEIF iNumber >= 900 THEN 
            sNumeral = sNumeral + 'CM';
            iNumber = iNumber - 900;
        ELSEIF iNumber >= 500 THEN
            sNumeral = sNumeral + 'D'; 
            iNumber = iNumber - 500;
        ELSEIF iNumber >= 400 THEN 
            sNumeral = sNumeral + 'CD'; 
            iNumber = iNumber - 400;
        ELSEIF iNumber >= 100 THEN 
            sNumeral = sNumeral + 'C'; 
            iNumber = iNumber - 100;
        ELSEIF iNumber >= 90 THEN
            sNumeral = sNumeral + 'XC';
            iNumber = iNumber - 90; 
        ELSEIF iNumber >= 50 THEN 
            sNumeral = sNumeral + 'L'; 
            iNumber = iNumber - 50;
        ELSEIF iNumber >= 40 THEN 
            sNumeral = sNumeral + 'XL';
            iNumber = iNumber - 40;
        ELSEIF iNumber >= 10 THEN 
            sNumeral = sNumeral + 'X';
            iNumber = iNumber - 10;
        ELSEIF iNumber = 9 THEN 
            sNumeral = sNumeral + 'IX';
            iNumber = 0;
        ELSEIF iNumber >= 5 THEN 
            sNumeral = sNumeral + 'V';
            iNumber = iNumber - 5;
        ELSEIF iNumber = 4 THEN 
            sNumeral = sNumeral + 'IV';
            iNumber = 0;
        Else 
            sNumeral = sNumeral + 'I';
            iNumber = iNumber - 1;
        ENDIF; 
    ENDWHILE; 
    RETURN sNumeral;
}

 

You can of course apply lowercase() to the return value if required.

 

Bodo.

Bodo Bergmann | Sr. Software Engineer | Bodo.Bergmann at ingres.com
<mailto:Bodo.Bergmann at ingres.com>  | Ingres Germany GmbH | Ohmstr. 12 |
63225 Langen | GERMANY | +49 6103 9881 0

 

________________________________

From: openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] On Behalf Of Bloomfield,
Martin (PSD)
Sent: Wednesday, July 02, 2008 12:40 PM
To: International OpenROAD Users
Subject: [Openroad-users] Convert numbers to Roman

I'm in the middle of a project and need to build some dynamic text using
item numbers in Roman numerals (e.g. "for items i - iv the expiry date
is 2/12/08", "for items i, v - ix the expiry date is 31/12/2010").  I
have the required data (item number and date) in an array with the
required numbers stored as integers (1, 3, 4 etc).   Before  I try to
work out how to convert these to Roman numerals (i, iii, iv), I was
wondering if anyone has done this before and would be willing to share
the code they used.  I'm using OpenROAD 4.1 SP2 on Windows XP with
Ingres/Net 2.6.

Any assistance would be appreciated,

Thanks in advance,

Martin Bloomfield.
_________________________________________________
Application Developer & Database Administrator
IT Branch,
Pesticides Safety Directorate
YORK 

Email: martin.bloomfield at psd.hse.gsi.gov.uk
<mailto:martin.bloomfield at psd.hse.gsi.gov.uk> 
Website: www.pesticides.gov.uk <http://www.pesticides.gov.uk/>  

P Save a tree... please don't print this e-mail unless you really need
to 

PSD joined the Health and Safety Executive on 1st April 2008. All email
addresses changed to firstname.surname at psd.hse.gsi.gov.uk from that
date.  Email sent to the previous addresses will continue to be
delivered until at least September 2008, but please update your mailing
lists or contacts as soon as you can to reflect the change.

__________________________________________________________________



************************************************************************
***********
Please note: Incoming and outgoing e-mail messages are routinely
monitored for compliance with our policy on the use of electronic
communications.

Interested in Occupational health and safety information?
Please visit the HSE website at the following address to
keep yourself up to date.

www.hse.gov.uk

or Contact HSE Infoline on 0845 345 0055 or Email on
hse.infoline at natbrit.com

************************************************************************
***********

The original of this email was scanned for viruses by the Government
Secure Intranet virus scanning service supplied by Cable&Wireless in
partnership with MessageLabs. (CCTM Certificate Number 2007/11/0032.) On
leaving the GSi this email was certified virus free.
Communications via the GSi may be automatically logged, monitored and/or
recorded for legal purposes.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.peerlessit.com/pipermail/openroad-users/attachments/20080702/1c78c8c5/attachment.html 


More information about the Openroad-users mailing list