[24 Dec 2009] is it possible to use: openfile(1, "fileX") when x differs?

Contains all messages from the Hollywood mailing list between 01/2006 and 08/2012
Locked
Bugala
Posts: 1180
Joined: Sun Feb 14, 2010 7:11 pm

[24 Dec 2009] is it possible to use: openfile(1, "fileX") when x differs?

Post by Bugala »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 24 Dec 2009 09:52:27 -0000

i have this level tables as saved files.

Now i would like to use somethinglike:

Code: Select all

X=1 (for example)
Openfile(1, "levelX.bin")
For it to open file level1.bin or if X being 2, then level2.bin and so on.

I can do this way in perl, but is there a way to do this same in Hollywood?
GMKai
Posts: 140
Joined: Mon Feb 15, 2010 10:58 am

[24 Dec 2009] Re: is it possible to use: openfile(1, "fileX") when x differs?

Post by GMKai »

Note: This is an archived post that was originally sent to the Hollywood mailing list on 24 Dec 2009 14:30:14 +0000

Hallo samuli,

you can use the operator ".." to concatenate strings

Code: Select all

num$="1"
filestring = "level"..num$..".bin"
Openfile(1,filestring)
PEB
Posts: 569
Joined: Sun Feb 21, 2010 1:28 am

[24 Dec 2009] Re: is it possible to use: openfile(1, "fileX") when x differs?

Post by PEB »

Note: This is an archived post that was originally sent to the Hollywood mailing list on Thu, 24 Dec 2009 08:03:10 -0800 (PST)

Concatenation automatically converts a number variable to a string. So all you need to do is use a line like this:

Openfile(1, "level"..X..".bin" )
Locked