Sign in to follow this  
Followers 0
FireLordZi

Extract date

8 posts in this topic

How can I extract the date from my ini that looks like this:

[section]

Key=value1;value2;value3;~February 1, 2008


While Alive() {
	 DrinkWine();
}
AutoIt Programmer

Share this post


Link to post
Share on other sites



$var = IniRead("file.ini","section","key","")
$var2 = StringSplit($var,";")
$date = StringTrimLeft($var2[UBound($var2)-1],1)

msgbox(1,"",$date)

Share this post


Link to post
Share on other sites

How can I extract the date from my ini that looks like this:

[section]

Key=value1;value2;value3;~February 1, 2008

IniRead() will get the value of "Key" for you. Then you just parse the string. One way to do that is use StringInStr() to find out where the tilde is, then use StringMid() to get the part of the string past that.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

@PsaltyDS and @ covaks:

Thanks for all your help! :) :)


While Alive() {
	 DrinkWine();
}
AutoIt Programmer

Share this post


Link to post
Share on other sites

$var = IniRead("C:\buddies.ini", "OnlineBuddies", "turnof", "Key not found.")
$var0 = StringSplit($var,";")
$var2 = StringSplit($var,"~")
$date1 = StringTrimLeft($var2[UBound($var2)-1],1)
msgbox(1,"",$date1)

I did that and it's returning /31/2008 at 3:47:07 PM when it is supposed to be returning 1/31/2008 at 3:47:07 PM

What's the problem?


While Alive() {
	 DrinkWine();
}
AutoIt Programmer

Share this post


Link to post
Share on other sites

$var = IniRead("C:\buddies.ini", "OnlineBuddies", "turnof", "Key not found.")
$var0 = StringSplit($var,";")
$var2 = StringSplit($var,"~")
$date1 = StringTrimLeft($var2[UBound($var2)-1],1)
msgbox(1,"",$date1)

I did that and it's returning /31/2008 at 3:47:07 PM when it is supposed to be returning 1/31/2008 at 3:47:07 PM

What's the problem?

AutoIT doesn't recognise month names as integers...i.e. the word February is not recognised as "2".

You will probably need to set up some sort of switch to account for this...

Switch $month
          case "January"
                  $month = "01"
          case "February"
                  $month = "02"
          case "March"
                  $month = "03"
          case "April"
                  $month = "04"

          ;etc, etc,

EndSwitch

- Table UDF - create simple data tables - Line Graph UDF GDI+ - quickly create simple line graphs with x and y axes (uses GDI+ with double buffer) - Line Graph UDF - quickly create simple line graphs with x and y axes (uses AI native graphic control) - Barcode Generator Code 128 B C - Create the 1/0 code for barcodes. - WebCam as BarCode Reader - use your webcam to read barcodes - Stereograms!!! - make your own stereograms in AutoIT - Ziggurat Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Box-Muller Gaussian Distribution RNG - generate random numbers based on normal/gaussian distribution - Elastic Radio Buttons - faux-gravity effects in AutoIT (from javascript)- Morse Code Generator - Generate morse code by tapping your spacebar!

Share this post


Link to post
Share on other sites

$sINI = "C:\Temp\Test.ini"
$sData = IniRead($sINI, "Section", "Key", "")
$sData = StringMid($sData, StringInStr($sData, "~") + 1)
ConsoleWrite("Debug: $sData = " & $sData & @LF)

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

$sINI = "C:\Temp\Test.ini"
$sData = IniRead($sINI, "Section", "Key", "")
$sData = StringMid($sData, StringInStr($sData, "~") + 1)
ConsoleWrite("Debug: $sData = " & $sData & @LF)

:)

Thanks!

While Alive() {
	 DrinkWine();
}
AutoIt Programmer

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