Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Logic Problem? Left bound > Right bound.
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic
Author Message
chrispminis




PostPosted: Sun Mar 19, 2006 8:14 pm   Post subject: Logic Problem? Left bound > 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.


TextCalculator2.t
 Description:
My text calc

Download
 Filename:  TextCalculator2.t
 Filesize:  4.61 KB
 Downloaded:  90 Time(s)

 
Sponsor
Sponsor
Sponsor
sponsor
MysticVegeta




PostPosted: Mon Mar 20, 2006 6:47 pm   Post subject: (No subject)

Where is the code?
 
person




PostPosted: Mon Mar 20, 2006 7:48 pm   Post subject: (No subject)

MysticVegeta wrote:
Where is the code?

What are u taling about?
 
Delos




PostPosted: Mon Mar 20, 2006 9:47 pm   Post subject: (No subject)

Your error appears to be here:

code:

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

code:

   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




PostPosted: Mon Mar 20, 2006 11:29 pm   Post subject: (No subject)

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.

code:
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) <= "9" then
            number *= 10
            number += (ord (str (i)) - 48)
        end if
    end for

    if dec = true then
        number := number / (10 ** (length (str) - mark))
    end if

    result number
end stringreal

get stringy : *
put stringreal (stringy (2 .. 4))
put stringreal (stringy (5 .. 7))
 
MysticVegeta




PostPosted: Tue Mar 21, 2006 6:45 pm   Post subject: (No subject)

Huh? Where is the code? I cant see it! Confused
 
chrispminis




PostPosted: Tue Mar 21, 2006 8:20 pm   Post subject: (No subject)

Um, either you're insane or I am, but since you have the history of being mentally unstable in this thread, im assuming its you. I see it fine.
 
MysticVegeta




PostPosted: Wed Mar 22, 2006 2:39 pm   Post subject: (No subject)

I am not joking, I cant see the attached file (if there is any)
 
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Wed Mar 22, 2006 6:11 pm   Post subject: (No subject)

either:
1)ur insane
2)ur blind
3)ur dumb
4)ur being an idiot
5)the initial post has the entire program
6)3 posts above this there is the problem area of his coding (which i cant find out is wrong with it btw) which is causing the problem
 
[Gandalf]




PostPosted: Wed Mar 22, 2006 6:16 pm   Post subject: (No subject)

Either you truly are insane, or else something is blocking it on your end, since it definately works.

As seen here:
Posted Image, might have been reduced in size. Click Image to view fullscreen.
 
MysticVegeta




PostPosted: Wed Mar 22, 2006 6:40 pm   Post subject: (No subject)

Gandalf, I see the one you posted but I still cant see anything in his post. I am not idiot =\ but I am insane Smile Honestly guys, I dont see that attachment
 
Andy




PostPosted: Wed Mar 22, 2006 8:11 pm   Post subject: (No subject)

maybe chrispminis set an IQ filter so that people with IQ less than 110 arent allowed to look at his code
 
Delos




PostPosted: Wed Mar 22, 2006 8:20 pm   Post subject: (No subject)

Then how can you see it dodge?
/me grins...then sidesteps as a series of defective Radeons are thrown at me.
 
chrispminis




PostPosted: Wed Mar 22, 2006 10:45 pm   Post subject: (No subject)

Lol, well dont worry. It was stupid, i just forgot to set it back to zero Razz
 
MysticVegeta




PostPosted: Thu Mar 23, 2006 12:12 am   Post subject: (No subject)

Andy wrote:
maybe chrispminis set an IQ filter so that people with IQ less than 110 arent allowed to look at his code
Crying or Very sad God shalt punish you! Thou shalt not make fun of a person with reduced mental mobility.
Quote:
Lol, well dont worry. It was stupid, i just forgot to set it back to zero

Ok, am i supposed to say it works now Question cuz it doesn't Razz
 
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh pageAdd this topic to your bookmarks (CTRL-D) View next topic

Page 1 of 2  [ 16 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: