• Support
  • Articles
  • Resources
  • Products

Multiple Sub Routine Call and Return points ('compound' sub routine)

Moderator: boris

7 postsPage 1 of 1

stevo
Newbie

Posts:
19
Joined: Tue Oct 15, 2013 11:08 pm
by stevo » Wed Dec 16, 2015 11:04 pm
You can cross multiple Sub routines and Return/Exit points.
You might want to assign different values or use different variables based on different calling criteria.

Thanks Boris and The TeraTerm Project!

I hope you find this interesting and useful :)

Code: Select all

  1.  
  2. CLOSETT ; not needed for testing
  3. ;=================================================================================
  4. :Main
  5.     TRUE  = 1
  6.     FALSE = 0
  7.    
  8.     For x 1 5
  9.         THISCALLED = TRUE
  10.         if x = 1 || x = 2 call Sub1
  11.         if x = 3 || x = 4 call Sub2
  12.         if x = 5 call Sub3
  13.         messagebox msg 'msg'
  14.     Next
  15.    
  16.     messagebox 'If you see this without seeing any errors, then it works! You can have multiple "RETURN" points within a single subroutine' 'SUCCESS!! :)'
  17. END
  18. ;=================================================================================
  19. ; 'COMPOUND' SUB-ROUTINE - mulitple entry points and multiple exit/return points
  20. ;=================================================================================
  21. :Sub1
  22.     if THISCALLED = TRUE then ; if this is the Sub that was called, then this will be TRUE, else it will be FALSE
  23.         SUBCALLED = 'Sub1'
  24.         THISCALLED = FALSE
  25.     endif
  26. :Sub2
  27.     if THISCALLED = TRUE then
  28.         SUBCALLED = 'Sub2'
  29.         THISCALLED = FALSE
  30.     endif
  31. :Sub3
  32.     if THISCALLED = TRUE then
  33.         SUBCALLED = 'Sub3'
  34.         THISCALLED = FALSE
  35.     endif
  36.     ;-----------------------------------------------------------------------------
  37.    
  38.     if x = 1 || x = 3 then
  39.         Sprintf2 msg 'Sub Called = %s; x = %d; x is ODD' SUBCALLED x
  40.         RETURN
  41.     elseif x = 2 || x = 4 then
  42.         Sprintf2 msg 'Sub Called = %s; x = %d; x is EVEN' SUBCALLED x
  43.         RETURN
  44.     else
  45.         Sprintf2 msg 'Sub Called = %s; x = %d; x is FIVE' SUBCALLED x
  46.     endif
  47. RETURN
  48. ;=================================================================================
  49.  
boris
Moderator, LogMeTT and TTLEditor developer

Posts:
1618
Joined: Sat Jan 08, 2005 2:52 pm
by boris » Thu Dec 17, 2015 12:45 am
Tested, works perfectly. Thanks for sharing this, stevo!!

Best regards,
Boris
smogmanus
Newbie

Posts:
1
Joined: Wed May 24, 2017 9:02 pm
by smogmanus » Thu Jan 25, 2018 6:15 am
Are there scripts posted I don't see how to obtain them.
boris
Moderator, LogMeTT and TTLEditor developer

Posts:
1618
Joined: Sat Jan 08, 2005 2:52 pm
by boris » Thu Jan 25, 2018 9:14 pm
It appears that recent upgrade of PHP from version 5 to version 7 done by our hosting provider broke the source code highlighter and all the scripts samples disappeared.
I will look into this and try to fix it.
Thanks.
Best regards,
Boris
boris
Moderator, LogMeTT and TTLEditor developer

Posts:
1618
Joined: Sat Jan 08, 2005 2:52 pm
by boris » Fri Jan 26, 2018 3:16 pm
Quick update: I was able to confirm that scripts disappeared after PHP5 to PHP7 upgrade. Yesterday I built VM on my laptop running web server with PHP5 and imported pre-PHP7 backup of the site. Everything worked as it should. However, the bad news is that this forum software contains over 140 files using PHP commands depreciated in PHP7 and fixing them will take quite some time.
Another option would be to upgrade forum software to the latest version that supports PHP7, but unfortunately the latest version is not compatible with layout templates used in earlier versions. This means such upgrade will turn into rebuilding of the entire website that will take even longer than patching the files.
Thanks.
Best regards,
Boris
boris
Moderator, LogMeTT and TTLEditor developer

Posts:
1618
Joined: Sat Jan 08, 2005 2:52 pm
by boris » Mon Feb 05, 2018 3:05 pm
I hope I managed to patch all the files and the forums are back to normal with all scripts visible and file upload working again.
Please let me know if you experience any other issues.
Thanks.
Best regards,
Boris
IshmaelCallMe
Guru

Posts:
676
Joined: Thu Jan 26, 2006 2:28 am
by IshmaelCallMe » Mon Feb 05, 2018 3:36 pm
Thanks, Boris! Your work on these forums is appreciated.
Display posts from previous:
Sort by:

7 postsPage 1 of 1

Users browsing this forum: No registered users
cron