Jump to content
Sign in to follow this  
colafrysen

How to "activate" variables

Recommended Posts

colafrysen

Hi, i am writing a file that saves files, the filenames are custom named by the users via a ini-File.

I want to be able to use variables like time and date inside the ini-file to use in the filename, for example.

INI-File:

[File]

Name=File1%Month%-%Date%

Where %Month% and %Date% will be equal to the AutoIt macros @mon and @mday

Help appreciated :)


[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]

Share this post


Link to post
Share on other sites
colafrysen

Then just do:

Name=File1 & @MON&-&@mDAY
Thanks, but the syntax for the AutoIt strings with the "&" and quotes are a bit to hard for the people who are going to use this application.

so even though it would work I want an easier syntax.


[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]

Share this post


Link to post
Share on other sites
James

Thanks, but the syntax for the AutoIt strings with the "&" and quotes are a bit to hard for the people who are going to use this application.

so even though it would work I want an easier syntax.

Well think about it :) Just convert it in script.

Share this post


Link to post
Share on other sites
PsaltyDS

Thanks, but the syntax for the AutoIt strings with the "&" and quotes are a bit to hard for the people who are going to use this application. so even though it would work I want an easier syntax.

If you have no intention of learning AutoIt, then stop using AutoIt, and please stop posting in AutoIt forums.

If, however, you want to learn, the syntax of what JamesBrooks gave you was not valid for use in a script. It whould have been:

$Name = "File1" & @MON & "-" & @MDAY

Saving that value to an ini file would be:

IniWrite($sIniFile, "Section_Name", "Name", "File1" & @MON & "-" & @MDAY)

If that doesn't cover your usage then be more clear about what you want to do.

:)


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
colafrysen

First, I really want to learn AutoIt, big time.

well i got this far

#include <Date.au3>

$input = "File1%time%-%date%.jpg"
$input2 = '"'&$input&'"'
$Time = @HOUR&":"&@MIN
$input3 = StringReplace ($input2,"%time%",'"&$time&"')
$Date = _DateTimeFormat( _NowCalc(),2)
$input4 = StringReplace ($input3,"%date%",'"&$Date&"')
MsgBox(1,$input,$input4)

Bot how do i make AutoIt recognise the contents of $input 4 as code, and not just a string.

Just tell me if I am unclear

and thanks for all the quick replies :)


[font="Impact"]Use the helpfile, It´s one of the best exlusive features of Autoit.[/font]http://support.microsoft.com/kb/q555375ALIBI Run - a replacement for the windows run promptPC Controller - an application for controlling other PCs[size="1"]Science flies us to the moon. Religion flies us into buildings.[/size][size="1"]http://bit.ly/cAMPZV[/size]

Share this post


Link to post
Share on other sites
PsaltyDS

First, I really want to learn AutoIt, big time.

well i got this far

#include <Date.au3>

$input = "File1%time%-%date%.jpg"
$input2 = '"'&$input&'"'
$Time = @HOUR&":"&@MIN
$input3 = StringReplace ($input2,"%time%",'"&$time&"')
$Date = _DateTimeFormat( _NowCalc(),2)
$input4 = StringReplace ($input3,"%date%",'"&$Date&"')
MsgBox(1,$input,$input4)

Bot how do i make AutoIt recognise the contents of $input 4 as code, and not just a string.

Just tell me if I am unclear

and thanks for all the quick replies :lmao:

I think you might be looking for Execute():
#include <Date.au3>

$input = "File1%time%-%date%.jpg"
ConsoleWrite("Debug: $input = " & $input & @LF)
$input2 = '"'&$input&'"'
ConsoleWrite("Debug: $input2 = " & $input2 & @LF)
$time = @HOUR&":"&@MIN
ConsoleWrite("Debug: $time = " & $time & @LF)
$input3 = StringReplace ($input2,"%time%",'"&$time&"')
ConsoleWrite("Debug: $input3 = " & $input3 & @LF)
$Date = _DateTimeFormat( _NowCalc(),2)
ConsoleWrite("Debug: $Date = " & $Date & @LF)
$input4 = StringReplace ($input3,"%date%",'"&$Date&"')
ConsoleWrite("Debug: $input4 = " & $input4 & @LF)
$sResult = Execute($input4)
ConsoleWrite("Debug: $sResult = " & $sResult & @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

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  

×