Jump to content
Sign in to follow this  
Damein

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

Recommended Posts

Damein

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

Share this post


Link to post
Share on other sites
Damein

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

Share this post


Link to post
Share on other sites
bestsmr

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

Share this post


Link to post
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
Sign in to follow this  

×