[Openroad-users] Convert numbers to Roman

Bloomfield, Martin (PSD) Martin.Bloomfield at psd.hse.gsi.gov.uk
Wed Jul 2 22:25:03 EST 2008


Bodo,

 

Thanks for the reply.  That works a treat.  

Martin Bloomfield. 

From: openroad-users-bounces at peerlessit.com
[mailto:openroad-users-bounces at peerlessit.com] On Behalf Of Bodo
Bergmann
Sent: Wednesday, July 02, 2008 12:51 PM
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.

This email was received from the INTERNET and scanned by the Government
Secure Intranet anti-virus service supplied by Cable&Wireless in
partnership with MessageLabs. (CCTM Certificate Number 2007/11/0032.) In
case of problems, please call your organisation's IT Helpdesk. 
Communications via the GSi may be automatically logged, monitored and/or
recorded for legal purposes.


 

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.
__________________________________________________________________

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/b5489ece/attachment.html 


More information about the Openroad-users mailing list