I'm writing a calculator program that receives a string and returns the result (everything in console mode), using Delphi 6. I use a FOR to advance and evaluate the sub-expressions, but the compiler leaves the FOR without reason (I mean that Delphi does not give me any warnings or errors, it simply skips the rest of the FOR begin-end sentence).

I'd like to know if I can edit the debugger options to prevent this kind of behaviour.

What does your for loop code look like? The compiler obviously has a reason to skip!

This is the FOR:

for j:=1 to cant_op do

"cant_op" counts how many times the program evaluates a mathematical sub_expression. its minimum value is 1, so the for executes at least once.

"extract_sub" takes a long expression and copies the first level of parenthesis into sub_expres

"alfa" and "lambda" are used later so that the sub_expression is deleted from the main string appropriately

"op_entre_term" is a custom function; it works properly but never returns its result into "number" (they are of the same type, real). the bold line is the last one the compiler reads before skipping into the next sentence, thus quitting the FOR sentence.

any clues? :)

sorry for asking the obvious but what happens if you put in a breakpoint and step into (f7): number:=op_entre_term(sub_expres);

do you have error trapping? i'd put a watch on each of the variables you're dealing with too.

This article has been dead for over six months. Start a new discussion instead.