LB Booster
« Store and une a filename in a variable »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:45am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Store and une a filename in a variable  (Read 159 times)
flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx Store and une a filename in a variable
« Thread started on: Jun 18th, 2017, 05:52am »

Hi,

I'm trying to improve a small program I just finished and one point would be to handle BMP files via a variable (ImageFile$) instead of having to name each file every time.

The purpose of the program is to display the actual kind of dance played and the user can select them by directly clicking on each image's list (easy to understand - I wish I could attach some images).

Code:
' Image Launcher short

NOMAINWIN

   WindowWidth = 1920
   WindowHeight = 1080

   LOADBMP "BackgroundImage",".\Aucune.bmp"

   GRAPHICBOX #MainWindow.GBx1,0,0,1920,1080
   STYLEBITS  #MainWindow.GBx1,0,_WS_BORDER,0,0

[MAIN]
   OPEN "Display BMP image" FOR window_popup AS #MainWindow
   #MainWindow "TRAPCLOSE [QUIT_MAIN_WINDOW]"
   #MainWindow.GBx1 "down"
   #MainWindow.GBx1 "drawbmp BackgroundImage 0 0"
   #MainWindow.GBx1 "when leftButtonDown [MouseLeftButton]"
   WAIT

[MAIN_REFRESH]
'***
LOADBMP "BackgroundImage",ImageFile$
'***
   #MainWindow.GBx1 "down"
   #MainWindow.GBx1 "drawbmp BackgroundImage 0 0"
   WAIT

[QUIT_MAIN_WINDOW]
   CLOSE #MainWindow
   END

[MouseLeftButton]
   IF (MouseX > 1685 AND MouseX < 1770) THEN    'Aucune
      IF (MouseY > 1055 AND MouseY < 1069) THEN
         UNLOADBMP "BackgroundImage"
'****
         'LOADBMP "BackgroundImage",".\Aucune.bmp"
ImageFile$ = ".\Aucune.bmp"
'****
         GOTO [MAIN_REFRESH]
      END IF
   END IF

   IF (MouseX > 603 AND MouseX < 671) THEN    'Bachata
      IF (MouseY > 962 AND MouseY < 979) THEN
         UNLOADBMP "BackgroundImage"
'****
         'LOADBMP "BackgroundImage",".\Bachata.bmp"
ImageFile$ = ".\Bachata.bmp"
'****
         GOTO [MAIN_REFRESH]
      END IF
   END IF

   IF (MouseX > 207 AND MouseX < 315) THEN    'Cha-Cha-Cha
      IF (MouseY > 919 AND MouseY < 935) THEN
         UNLOADBMP "BackgroundImage"
'****
         'LOADBMP "BackgroundImage",".\Cha-Cha-Cha.bmp"
ImageFile$ = ".\Cha-Cha-Cha.bmp"
'****
         GOTO [MAIN_REFRESH]
      END IF
   END IF

   IF (MouseX > 1820 AND MouseY > 1045) THEN GOTO [QUIT_MAIN_WINDOW] ' "Quitter"
   WAIT 

The changes are between '*** .

NB: how do I attach a file to the thread?
User IP Logged

Roger
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Store and une a filename in a variable
« Reply #1 on: Jun 18th, 2017, 4:04pm »

on Jun 18th, 2017, 05:52am, flotulopex wrote:
one point would be to handle BMP files via a variable (ImageFile$) instead of having to name each file every time.

What's the problem? Are you saying that this line from your program isn't working:

Code:
LOADBMP "BackgroundImage",ImageFile$ 

Even the LBB docs show a variable being used for the filename, so it should certainly be OK.

Quote:
NB: how do I attach a file to the thread?

You can't, as far as I know.

Richard.
User IP Logged

flotulopex
Junior Member
ImageImage


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 94
xx Re: Store and une a filename in a variable
« Reply #2 on: Jun 19th, 2017, 09:50am »

I had to do it this way:

Code:
...
[MAIN_REFRESH]
   UNLOADBMP "BackgroundImage"
   LOADBMP ".\" + ImageFile$ + ".bmp"
   #MainWindow.GBx1 "down"
   #MainWindow.GBx1 "drawbmp BackgroundImage 0 0"
   WAIT

...
[MouseLeftButton]
   IF (MouseX > 1685 AND MouseX < 1770) THEN    'Aucune
      IF (MouseY > 1055 AND MouseY < 1069) THEN
         ImageFile$ = "Aucune"
         GOTO [MAIN_REFRESH]
      END IF
   END IF 
User IP Logged

Roger
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Store and une a filename in a variable
« Reply #3 on: Jun 19th, 2017, 1:35pm »

on Jun 19th, 2017, 09:50am, flotulopex wrote:
I had to do it this way

I'm not too sure what point you are making. The leading ".\" to the file specification doesn't achieve anything ('dot' is the current directory anyway); you would probably be better to use DefaultDir$ like this:

Code:
LOADBMP "BackgroundImage", DefaultDir$ + "\" + ImageName$ + ".bmp" 

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls