In other pascal languages I've used you can put procedures inside other procedures like this: Code (Text): procedure outsideprocedure var oustidevar : integer; procedure insideprocedure var insidevar : string; begin <insidecodehere> end; //end inside procedure begin <outsidecodehere> end; //end outside procedure but in SCAR when I do this i get a message saying begin expected on the : "procedure insideprocedure" line. How can I nest succesfully?!
Is it necessary to nest the procedures? Possible to just move the begin since originally the inside procedure wasn't inside the outside procedure? Code (Text): procedure outsideprocedure var oustidevar : integer; begin procedure insideprocedure; var insidevar : string; begin <insidecodehere> end; //end inside procedure <outsidecodehere> end; //end outside procedure or Can't you just call the inside procedure from outside procedure like : Code (Text): procedure insideprocedure; var insidevar : string; begin <insidecodehere> end; //end inside procedure procedure outsideprocedure; var oustidevar : integer; begin insideprocedure; <outsidecodehere> end; //end outside procedure I don't know the benefits of nesting procedures like that since you still have to call it for it to fire.
the only thing you need to know about this is that the procedure you're calling MUST be before the caller. Code (Text): procedure IWasCalled begin Blah Blah; end; procedure IMCalling begin IWasCalled; end;
Thanks you guys, I have managed to make it work now.The reason I wanted it nested was so that it could use the variables of the outside procedure, but without making them global. I've rewritten my code so that this is less of a problem. Thanks!