[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result
[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result
Pete's QBASIC Site Discuss QBasic, Freebasic, QB64 and more 2013-06-27T12:52:58-05:00 http://petesqbsite.com/phpBB3/app.php/feed/topic/3762 2013-06-27T12:52:58-05:00 2013-06-27T12:52:58-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=22692#p22692 <![CDATA[Re: How to convert letters to numbers?]]> this topic, I certainly remember you. That was the last time I programmed something. By the way, I didn't see your last message there, but I didn't have a problem with SLEEP. Basically I added a DO LOOP that kept the program running unaltered until you press Esc, which ends the program. I got a bit offtopic here :P

On to the topic, the actual converter was easy to do once I could atribute the input letters their Arabic values. I just had to sum up all the values and then check if there was a number at the right greater than one adjacent at the left, for all the numbers. If that's the case, it just deducts the smaller number twice from the total amount (one to fix the previous sum and one to do the actual deduction).

Code:

IF r1 < r2 THEN r0 = r0 - (2 * r1)
All in all it was a nice code to work on, I made all of it today because I missed the challenge of creating a functional program.

Thanks for your help.

Statistics: Posted by SoKeT — Thu Jun 27, 2013 12:52 pm


]]>
2013-06-27T07:40:58-05:00 2013-06-27T07:40:58-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=22691#p22691 <![CDATA[Re: How to convert letters to numbers?]]>

Code:

IF r1$ = "M" then r1 = 1000...IF r1$ = "C" then r1 = 100...IF r1$ = "X" then r1 = 10
Roman numerals are difficult to translate to numerical values as the positioning can determine if the value is added or subtracted. XI = 11 while IX = 9.
So you will have to not only determine each letter value, but you will have to consider the position of that value in the letter string.

The first thing to do is scan the Roman Numeral string:

Code:

INPUT "Enter a valid Roman Number: ", r$L = LEN(r$)REDIM Array(L)FOR i = 1 TO L  temp$ = MID$(r$, i, 1)  SELECT CASE temp$      CASE "I":  Array(i) = 1      CASE "V": Array(i) = 5      CASE "X": Array(i) = 10      '... L , D, M , etc     CASE ELSE: Array(i) = 0  'eliminate irrelevant letters  END SELECTNEXT i
I just put each letter value into an array, but you could use a FOR counter loop to do the calculations too.
You can check the Array to determine when greater values follow or precede lower values also.

Statistics: Posted by burger2227 — Thu Jun 27, 2013 7:40 am


]]>
2013-06-27T07:29:27-05:00 2013-06-27T07:29:27-05:00 http://petesqbsite.com/phpBB3/viewtopic.php?p=22690#p22690 <![CDATA[How to convert letters to numbers?]]>

Code:

INPUT "Roman Number: ", r$r1$ = MID$(r$, 1, 1)r2$ = MID$(r$, 2, 1)r3$ = MID$(r$, 3, 1)...r15$ = MID$(r$, 15, 1)'This takes each of the input characters into a different variable. I made 15 because that's the maximum amount of numbers in the Roman numerals (MMMDCCCLXXXVIII)
Now I have to convert each letter to it's corresponding value, and then Calculate the arabic number using a formula that I already have. The only thing I could think to accomplish this is the following:

Code:

IF r1$ = "M" then r1$ = 1000...IF r1$ = "C" then r1$ = 100...IF r1$ = "X" then r1$ = 10...
7 different letters by 15 maximum letters = 105 lines of code. It's not optimal, but I would have been happy if it worked. Sadly, it didn't. An error that says something like "Types don't match" appears on the bolded part: r1$ = 1000

Is there a way to solve this by changing the variable type or do I have to rethink the whole thing differently?

Statistics: Posted by SoKeT — Thu Jun 27, 2013 7:29 am


]]>