+OLD CS1 Posted January 31, 2011 Share Posted January 31, 2011 In C++ (probably C, as well, but I cannot recall off the top of my head,) you can set up multiple functions to accept calls depending upon the arguments passed. This is not possible with TI Extended BASIC using the SUB command and, in fact, TI Extended BASIC starts looking for user sub-programs from the end of the program. For instance, given the code below lines 20 and 40 will return an INCORRECT ARGUMENT LIST error (error 81 in the program output,) whereas line 60 will pass just fine. The first two SUBs are ignored in favor of the last. 10 ON ERROR 100 20 CALL TEST 30 ON ERROR 100 40 CALL TEST(1) 50 ON ERROR 100 60 CALL TEST(2,3) 70 STOP 100 CALL ERR(A,B,C,D):: PRINT "ERROR";A;"IN LINE";D :: RETURN NEXT 200 SUB TEST :: PRINT "TEST" :: SUBEND 300 SUB TEST(A):: PRINT "TEST(A)" :: SUBEND 400 SUB TEST(A,B):: PRINT "TEST(A,B)" :: SUBEND 500 END Does this type of sub-program overloading work with any Extended BASIC beyond TI's? Quote Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.