BBC BASIC for Windows
Programming >> BBC BASIC language >> *DISPLAY Command
http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1444376576

*DISPLAY Command
Post by basscott on Oct 9th, 2015, 07:42am

Dependent upon the value of a variable (see below) I am trying to display 1 of 25 BMP files (named 1.BMP to 25.BMP) and can do it fairly easily with 25 lines but would like to try to do it in less lines, as follows: -

A%=G(25,1): *DISPLAY A% 240,350

It seems that the *DISPLAY command will not take a variable such as A%.

Is there any way that I can do this without having to name each file over 25 lines of code ?
Re: *DISPLAY Command
Post by sbracken on Oct 9th, 2015, 09:55am

You need to use the OSCLI command to pass variables to any star command, which is documented in the supplied help file, or on line here:

http://bbcbasic.co.uk/bbcwin/manual/bbcwin8.html#accessing

You also need to convert A% to a string, as BB4W will not do this for you and will throw a "Type mismatch" error. So, for your example, you need something like:

Code:
 OSCLI "DISPLAY """+STR$(A%)+".bmp"+""" 240,350"
 


However, usless there is a pressing for it elsewhere in your program, you can get rid of A% entirely and use the original array in the OSCLI command:

Code:
 OSCLI "DISPLAY """+STR$(G(25,1))+".bmp"+""" 240,350"
 


Note the use of multiple quote marks to "escape" the quotes needed for the name supplied to the DISPLAY command.

Simon
Re: *DISPLAY Command
Post by basscott on Oct 9th, 2015, 3:05pm

Excellent - works perfectly and just what I wanted.

That's another fact learned smiley

Thanks a lot for helping.