Sign in to follow this  
Followers 0
jben

Reading an .ini problem

4 posts in this topic

#1 ·  Posted (edited)

Hey. Can someone help me with solving my ini file issue..

I'm trying to read in 2 different pieces of information and use this info for the dirmove. The ini would look like this

[section1]

location=something

destination=something

[section2]

location=something

destination=something

[section3]

location=something

destination=something

My code is below. Thanks

#include <date.au3>
Dim $date[3]=[@YEAR,@MON,@MDAY]
$inputlocation = @TempDir&"\XS_TEMP2";Location to obtain extracted files
$outputlocation = "C:\OUTPUT\";location to output files
$foldername = @YEAR & _WeekNumberISO()
If Not FileExists($outputlocation) Then DirCreate($outputlocation);creates the dir if it doesn't exist

;************INI TEST*****************
$sections = IniReadSectionNames ("C:\Documents and Settings\myname\Desktop\INI TEST\locations.ini");reads the sections

$filetoextract = IniRead ("C:\Documents and Settings\myname\Desktop\INI TEST\locations.ini",$sections,"Filetoextract", "default");gets file to extract

$locationtosave = IniRead ("C:\Documents and Settings\myname\Desktop\INI TEST\locations.ini",$sections,"Locationtosave", "default");gets location to save

DirMove($inputlocation & $filetoextract,$outputlocation & $locationtosave)
Edited by jben

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

IniReadSectionNames returns an array.

Success: Returns an array of all section names in the INI file.

Failure: Sets @error on failure.

Should do something like the following:

$filetoextract = IniRead ("C:\Documents and Settings\myname\Desktop\INI TEST\locations.ini",$sections[0],"Filetoextract", "default");gets file to extract
Edited by DarkMatter

[sub]Quantum mechanics: The dreams stuff is made of[/sub]

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Hey. Can someone help me with solving my ini file issue..

I'm trying to read in 2 different pieces of information and use this info for the dirmove. The ini would look like this

[section1]

location=something

destination=something

[section2]

location=something

destination=something

[section3]

location=something

destination=something

My code is below. Thanks

#include <date.au3>
 Dim $date[3]=[@YEAR,@MON,@MDAY]
 $inputlocation = @TempDir&"\XS_TEMP2";Location to obtain extracted files
 $outputlocation = "C:\OUTPUT\";location to output files
 $foldername = @YEAR & _WeekNumberISO()
 If Not FileExists($outputlocation) Then DirCreate($outputlocation);creates the dir if it doesn't exist
 
;************INI TEST*****************
 $sections = IniReadSectionNames ("C:\Documents and Settings\myname\Desktop\INI TEST\locations.ini");reads the sections
 
 $filetoextract = IniRead ("C:\Documents and Settings\myname\Desktop\INI TEST\locations.ini",$sections,"Filetoextract", "default");gets file to extract
 
 $locationtosave = IniRead ("C:\Documents and Settings\myname\Desktop\INI TEST\locations.ini",$sections,"Locationtosave", "default");gets location to save
 
 DirMove($inputlocation & $filetoextract,$outputlocation & $locationtosave)
Hello jben, having troubles gain? :D

IniReadSectionNames() return an array so this would be better:

#include <date.au3>
Dim $date[3]=[@YEAR,@MON,@MDAY]
$inputlocation = @TempDir&"\XS_TEMP2\";Location to obtain extracted files
$outputlocation = "C:\OUTPUT\";location to output files
$foldername = @YEAR & _WeekNumberISO()
If Not FileExists($outputlocation) Then DirCreate($outputlocation);creates the dir if it doesn't exist

$sections = IniReadSectionNames ("C:\Documents and Settings\myname\Desktop\INI TEST\locations.ini");reads the sections
If IsArray($sections) Then
For $section In $sections
$filetoextract = IniRead ("C:\Documents and Settings\myname\Desktop\INI TEST\locations.ini",$section,"Filetoextract", "default");gets file to extract

$locationtosave = IniRead ("C:\Documents and Settings\myname\Desktop\INI TEST\locations.ini",$section,"Locationtosave", "default");gets location to save

DirMove($inputlocation & $filetoextract,$outputlocation & $locationtosave)
Next
EndIf

Edit: Also fixed some backslash errors in your code :D

Edited by monoceres

Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

thanks... :D

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  
Followers 0