Jump to content

Best way to attach an image location to array/var?


Damein
 Share

Recommended Posts

Alright, so heres the deal. I have an ini file with sections such as:

Cakes

Drinks

Etc. etc.

In each section, there are specific items. For example.

[Cakes]

1=Chocolate

2=Vanilla

[Drinks]

1=Mt.Dew

2=Dr.Pepper

And for each of those in a seperate folder I have the images correspondingly.

So I have in /Imgs/Cakes

Chocolate.jpg

Vanilla.jpg

And in /Imgs/Drinks

Mt.Dew.jpg

Dr.Pepper.jpg

And I want to be able to attach the images to the variable that I read from the ini for quick use in a GUI.

I am currently using the default INIReadSection for this:

Global $Cakes[100][100], $Drinks[100][100]
 
$Cakes = IniReadSection("Database.ini", "Cakes")
If @error Then
    MsgBox(48, "", "Error loading database. Please ensure the Database.ini file is located in the same location as the .exe")
Else
    For $i = 1 To $Cakes[0][0]
        $Scout
        MsgBox(4096, "", "Key: " & $Cakes[$i][0] & @CRLF & "Value: " & $Cakes[$i][1])
Next
 
$Drinks = IniReadSection("Database.ini", "Drinks")
If @error Then
    MsgBox(48, "", "Error loading database. Please ensure the Database.ini file is located in the same location as the .exe")
Else
    For $i = 1 To $Drinks[0][0]
        $Scout
        MsgBox(4096, "", "Key: " & $Drinks[$i][0] & @CRLF & "Value: " & $Drinks[$i][1])
    Next

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

There's no way to create like a.. third value in an array, right? Like, have some sort of separator in the INI with a third section for the destination for the img?

MCR.jpg?t=1286371579

Most recent sig. I made

Quick Launcher W/ Profiles Topic Movie Database Topic & Website | LiveStreamer Pro Website | YouTube Stand-Alone Playlist Manager: Topic | Weather Desktop Widget: Topic | Flash Memory Game: Topic | Volume Control With Mouse / iTunes Hotkeys: Topic | Weather program: Topic | Paws & Tales radio drama podcast mini-player: Topic | Quick Math Calculations: Topic

Link to comment
Share on other sites

try to you this section in your code

;read ini data
dim $Cakes = IniReadSection("Database.ini", "Cakes")
if @error then exit
;convert to array that have path of every image
dim $i,$cake_img[$Cakes[0][0]+1]
dim $folder =""; = your image folder
for $i=1 to $Cakes[0][0]
$cake_img[$i]=$folder & $Cakes[$i][1] & ".jpg"
MsgBox(0,"preview",$cake_img[$i])
Next
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...