View unanswered posts | View active topics It is currently Mon Apr 20, 2026 2:04 am



Reply to topic  [ 10 posts ] 
 referencing included subs 
Author Message
Ensign
User avatar

Joined: Tue Jul 21, 2009 2:37 pm
Posts: 241
Location: Ottawa, Canada
Unread post referencing included subs
So I do something like this from a script in the twx folder (c:\twx) that I load through the twx in-game script menu ($ssScriptname):

Code:
include "c:/twx/scripts/hd_include/util.ts"
gosub :util~subname


And then in util.ts I have something like this:
Code:
:subname
  echo ansi_15 "did some stuff"
return


but I always get a fatal run-time error when it's time to execute the sub... it can't find sub "util~subname".

Any ideas? I hate including all my subs explicitly... feels ridiculous.


Thu Oct 22, 2009 5:43 pm
Profile
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post Re: referencing included subs
Includes should be at the bottom, and put a halt before hand so they aren't called during runtime. Basically an include just takes the block of code and sticks it in the file. Also, your path might be a problem. You don't need to specify all of that, includes are assumed to be in dir of the calling script unless otherwise specified (hence why you should compile complex scripts before passing them out).

Try this:

Code:
gosub :util~subname

# -------
halt
# -------
include "hd_include/util.ts"
# -------

_________________
May the unholy fires of corbomite ignite deep within the depths of your soul...

1. TWGS server @ twgs.navhaz.com
2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads
3. Open IRC chat @ irc.freenode.net:6667 #twchan
4. Parrothead wrote: Jesus wouldn't Subspace Crawl.

*** SG memorial donations via paypal to: dpocky68@booinc.com
Image


Thu Oct 22, 2009 5:58 pm
Profile ICQ WWW
Ensign
User avatar

Joined: Tue Jul 21, 2009 2:37 pm
Posts: 241
Location: Ottawa, Canada
Unread post Re: referencing included subs
Thanks for the reply... still having problems. Here's the input and output:

c:\TWX\scripts\test_ExternalSub.ts
Code:
echo ansi_8 & "**.....     Calling TestExternalSub...**"
gosub :TestExternalSub~SubName
halt
include "hd_include/TestExternalSub.ts"


c:\TWX\scripts\hd_include\TestExternalSub.ts
Code:
:SubName
    echo ansi_15 & "**!!!!   TestExternalSub did some stuff.**"
return


output after sending "$sstest_ExternalSub" to twx

Quote:
Loading and compiling script: scripts\test_ExternalSub.ts

Command [TL=00:00:00]:[12085] (?=Help)? :

..... Calling TestExternalSub...

Script run-time error in 'TEST_EXTERNALSUB.TS': Goto label not found 'TESTEXTERN
ALSUB~SUBNAME', line 3

Script terminated: scripts\test_ExternalSub.ts


Pulling out my hair over this...


Sat Oct 24, 2009 12:01 pm
Profile
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post Re: referencing included subs
Is that the entire actual script? I don't see anything wrong at first glance... maybe it's the case, try all lowercase?

Are you sure the actual .ts is there in the includes, it's not .ts.txt or something like notepad is famous for?

_________________
May the unholy fires of corbomite ignite deep within the depths of your soul...

1. TWGS server @ twgs.navhaz.com
2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads
3. Open IRC chat @ irc.freenode.net:6667 #twchan
4. Parrothead wrote: Jesus wouldn't Subspace Crawl.

*** SG memorial donations via paypal to: dpocky68@booinc.com
Image


Sat Oct 24, 2009 12:46 pm
Profile ICQ WWW
Ambassador
User avatar

Joined: Wed Nov 12, 2008 8:57 am
Posts: 3554
Location: Long Beach, CA
Unread post Re: referencing included subs
include "scripts\hd_include\TestExternalSub.ts" ?

Helix

_________________
Helix
Do I really look like a guy with a plan? You know what I am? I'm a dog chasing cars.
Lest we forget
I had to ask myself WWSGD?


Sat Oct 24, 2009 12:57 pm
Profile WWW
Commander
User avatar

Joined: Tue Oct 07, 2003 2:00 am
Posts: 1134
Location: Augusta, GA
Unread post Re: referencing included subs
The problem is that you have the file extension in the include statement. Rather, it should read:
include "hd_include\TestExternalSub"

Hope you have some hair left ;)

+EP+

_________________
Claim to Fame: only guy to ever crack the TW haggle algorithm, and fig/shield/hold price formula, twice.


Sat Oct 24, 2009 1:07 pm
Profile WWW
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post Re: referencing included subs
Really? I reference scripts like that all the time in an include.

Here's a snippet from a script...

Code:
# Update figs
gosub :sector_fun~update_figs
waitFor "Sub-space comm-link terminated"

# Update limps?
if ($dpcr_require_limps = "Yes")
    send "'     *"
    gosub :sector_fun~update_limps
    waitFor "Sub-space comm-link terminated"
end


And later...

Code:
# -------------------------------------------------------------------
# Includes
include "dny_includes\sector_fun.ts"
include "dny_includes\fast_twarp.ts"
include "dny_includes\cn_settings.ts"
include "dny_includes\quickstats.ts"
include "dny_includes\getcourse.ts"
# -------------------------------------------------------------------


See, .ts =)

_________________
May the unholy fires of corbomite ignite deep within the depths of your soul...

1. TWGS server @ twgs.navhaz.com
2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads
3. Open IRC chat @ irc.freenode.net:6667 #twchan
4. Parrothead wrote: Jesus wouldn't Subspace Crawl.

*** SG memorial donations via paypal to: dpocky68@booinc.com
Image


Sat Oct 24, 2009 1:32 pm
Profile ICQ WWW
Ensign
User avatar

Joined: Tue Jul 21, 2009 2:37 pm
Posts: 241
Location: Ottawa, Canada
Unread post Re: referencing included subs
Yeah, the ts didn't make a difference, neither did Helix's suggestion, and neither did the lowercase...

Sing, yes those are the entire files. I've just tried saving all files with lowercase names, and changing the sub name and sub call and include statement to all lowercase.. same result...

Thanks for the help everyone... but still losing hair.

Oh yeah and Sing I don't use notepad... My editor's title bar shows the entire filepath of the file I'm editing, so I know the paths and filenames are correct.


Sat Oct 24, 2009 1:42 pm
Profile
Ensign
User avatar

Joined: Tue Jul 21, 2009 2:37 pm
Posts: 241
Location: Ottawa, Canada
Unread post Re: referencing included subs
It's working now!

replaced the forward slash in include statement with a backslash..

coulda sworn we were spose to use forward slashes...


Sat Oct 24, 2009 1:46 pm
Profile
Veteran Op
User avatar

Joined: Thu Jun 02, 2005 2:00 am
Posts: 5558
Location: USA
Unread post Re: referencing included subs
Oh yeh, twxproxy is slash sensitive. Forgot about that. Huh

Good to know.

_________________
May the unholy fires of corbomite ignite deep within the depths of your soul...

1. TWGS server @ twgs.navhaz.com
2. The NavHaz Junction - Tradewars 2002 Scripts, Resources and Downloads
3. Open IRC chat @ irc.freenode.net:6667 #twchan
4. Parrothead wrote: Jesus wouldn't Subspace Crawl.

*** SG memorial donations via paypal to: dpocky68@booinc.com
Image


Sat Oct 24, 2009 3:53 pm
Profile ICQ WWW
Display posts from previous:  Sort by  
Reply to topic   [ 10 posts ] 

Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by wSTSoftware.