
-----------------------------------
chrispminis
Sun Mar 19, 2006 8:14 pm

Logic Problem? Left bound &gt; Right bound.
-----------------------------------
Alright, I'm working on a text calculator, that was described here earlier. Currently I'm working on procedures that identify and prioritize certain symbols according to PEDMAS, and i just finished that. I just started working on a procedure that identifies numbers. I have managed to detect where numbers start and end, using my symbol markers... But the problem lies, when I attempt to use my custom strreal function to translate the numbers value, I get the error. Left bound of substring exceeds right bound by more than 1. The problem I think is just my logic, but I can't figure out my problem. If you need an explanation as to what the program as doing at that moment just ask. Well, run it and tell me what I did wrong.

-----------------------------------
MysticVegeta
Mon Mar 20, 2006 6:47 pm


-----------------------------------
Where is the code?

-----------------------------------
person
Mon Mar 20, 2006 7:48 pm


-----------------------------------
Where is the code?
What are u taling about?

-----------------------------------
Delos
Mon Mar 20, 2006 9:47 pm


-----------------------------------
Your error appears to be here:


   if symbol (j).sused then
      number (i).nend := symbol (j).smark
      exit
   end if

Your problem lies in your assignment of .nend, which apparently never has that clause initiate it!  Try it, echo an error message in an else condition to that clause and it should pop up quite frequently.

Also, notice the reformat I did of the code (very minor).


   if symbol (j).sused = true then
   % condensed to
   if symbol (j).sused then

This is possible due to the boolean nature of said variables.

-----------------------------------
chrispminis
Mon Mar 20, 2006 11:29 pm


-----------------------------------
Eum.. not sure exactly what you're talking about... but.. after a good (not really but still sleep is sleep) night's rest, the problem resolved itself. It turned out i was defining an invisible number past the last symbol, and since the invisible thing after that had a value of zero it was smaller. Instead I have another problem, but after a period of debugging ive isolated the problem. It lies within my emulated strreal function. The problem is that, if you'll see the test output at the end where stringy is a 7+ digit number, the first output works fine, but the second value returned also includes the first one? Try it with different combos and you'll see what I mean.

 var stringy : string
var number : real := 0
var mark : int
var dec : boolean := false

function stringreal (str : string) : real
    mark := index (str, ".")
    if mark > 0 then
        dec := true
    end if

    for i : 1 .. length (str)
        if str (i) >= "1" and str (i) 