Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Roman Numerals (DBC + DBP)

Author
Message
Andy Igoe
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 4th Jun 2003 02:30
Preface
I recently had need to convert a number to Roman Numerals and wrote a universal function for the task. Please feel free to use this function without credit.

Usage
string=romanNumeral(integer)

Limitation
The Roman Numeral for 5,000 is not present in the ASCII table, therefor the function can only return a value of 3,999 or less.

There's a 1000 diference? That is because the numeral for 4,000 actually uses the numeral for 5,000 to depict it.

The numeral itself is a V with a horizontal line above it, I have tried to use extended ASCII characters to reposition the cursor but DBPro doesn't seem to support that. This is not a failing of DBPro really as such conventions have not existed in the Windows era.

The Romans had no numeral for the number 0 and therefor cannot express negative numbers.

The function therefor is limited to the range 1-3999.
Pneumatic Dryll
http://www.users.globalnet.co.uk/~thane/char01.jpg[/img]
Blanka
21
Years of Service
User Offline
Joined: 26th Feb 2003
Location: United Kingdom
Posted: 18th Jun 2003 00:30
code only works once... then fails, see this example below



Andy Igoe
21
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 18th Jun 2003 22:48
I executed your example and it returned the correct result "C" every time.

Pneumatic Dryll
cusoi
21
Years of Service
User Offline
Joined: 3rd Jan 2003
Location: Netherlands
Posted: 19th Jun 2003 00:25
Not in DBC, in the function you should add numeral$="". Then it will work. In DBC the first time it gives "C" then "CC" then "CCC", you know what I mean. Maybe in DBPro the variable is a local variable that only exist in the function, but in DBC it remembers the variable. This way the function will be dbpro compatible:


Pentium IV 2.4 GHZ 256 MB Ram Geforce 4 TI 4200 128 MB
Visit my site: www.cuso.tk
Blanka
21
Years of Service
User Offline
Joined: 26th Feb 2003
Location: United Kingdom
Posted: 20th Jun 2003 02:37
Thanks for clearing that up RTSpider cheers

Login to post a reply

Server time is: 2024-04-18 08:35:18
Your offset time is: 2024-04-18 08:35:18