Page 1 of 1

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

Posted: Sat Jun 13, 2020 5:32 pm
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?

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

Posted: Sat Jun 13, 2020 5:32 pm
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)

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

Posted: Sat Jun 13, 2020 5:32 pm
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" )