# ini and @crlf

## Recommended Posts

I'm reading a entry in a ini file. It is a saved macro I wish to use. looks like this:

`<B>More Information:</B><BR>'&@CRLF&'&nbsp;&nbsp;`

What I need to happen is after I read the ini entry, the code will format it so when I do a controlsend it looks like this:

```<B>More Information:</B><BR>
&nbsp;&nbsp;```

What is wierd is if I do this, it works:

`ControlSend(\$hWnd,"","Edit1",'<B>More Information:</B><BR>'&@CR&'&nbsp;&nbsp;')`

If I do this:

```\$iniR20 = iniread(@ScriptDir&"/b_set.ini", "2", "1", "");allow for raw - I tried both 1 and 0, same result
\$iniR20a = iniread(@ScriptDir&"/b_set.ini", "2", "2", "")
ControlSend(\$hWnd,"","Edit1",\$iniR20a,\$iniR20)```

I get this for output:

`<B>More Information:</B><BR>'&@CRLF&'&nbsp;&nbsp;`

##### Share on other sites

I've tried to do stringReplace with using @LF to @CR, but no luck. This is quite puzzling. it is as if when one uses a INI, the data will be sent raw no matter if controlsend uses the 0 flag or the 1 flag. Very odd.

##### Share on other sites

Volly, the data is read as a string from the ini functions, so it's like wrapping it in quotes, which would make it "<B>More Information:</B><BR>'&@CRLF&'&nbsp;&nbsp;"

So...

`MsgBox(64, "info", "<B>More Information:</B><BR>'&@CRLF&'&nbsp;&nbsp;")`
would not separate the lines either.

The idea that if you manually separate the "string" into sections and it works is not "weird" in fact lol it's logical .

You would need to write a function to do that leg work for you.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

##### Share on other sites

I think you can solve this with Execute()

```\$iniR20 = iniread(@ScriptDir&"/b_set.ini", "2", "1", "");allow for raw - I tried both 1 and 0, same result
\$iniR20a = iniread(@ScriptDir&"/b_set.ini", "2", "2", "")
ControlSend(\$hWnd,"","Edit1",Execute(\$iniR20),Execute(\$iniR20a))```

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

##### Share on other sites

I think you can solve this with Execute()

```\$iniR20 = iniread(@ScriptDir&"/b_set.ini", "2", "1", "");allow for raw - I tried both 1 and 0, same result
\$iniR20a = iniread(@ScriptDir&"/b_set.ini", "2", "2", "")
ControlSend(\$hWnd,"","Edit1",Execute(\$iniR20),Execute(\$iniR20a))oÝ÷ Ûú®¢×¢}ý¶ØbA1yË­{¥
_IniExecuteMacro(\$sStrTest)
MsgBox(64, "info", \$sStrTest)

;You could add all the macros in this for a nice udf
;You could also use StringRegExpReplace so you don't replace the wrong thing... but this works for your need
Func _IniExecuteMacro(ByRef \$sString)
Local \$strMacro = StringSplit("@CRLF,@CR,@LF", ",");List could go on but you get the idea
Local \$m_Macro[4] = ["", @CRLF, @CR, @LF];List could go on but you get the idea
For \$iCC = 1 To \$strMacro[0]
\$sString = StringReplace(\$sString, \$strMacro[\$iCC], \$m_Macro[\$iCC])
Next;\$iCC
EndFunc```

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

##### Share on other sites

I even tried this, but no luck:

```\$rev1 = _StringReverse(\$iniR20)
\$rev2 = _StringReverse(\$rev1)```

no change.

I also tried to see if send would work any different. no luck.

I also thought it was a matter of quotes. I can send the string to Scite when using send, and it formats so that if I place the cursor inside the command in the correct spot, it formats right.

I did think of putting the entire command in the ini file, but how does one exacute the command?

##### Share on other sites

Volly, the data is read as a string from the ini functions, so it's like wrapping it in quotes, which would make it "<B>More Information:</B><BR>'&@CRLF&'&nbsp;&nbsp;"

So...

`MsgBox(64, "info", "<B>More Information:</B><BR>'&@CRLF&'&nbsp;&nbsp;")`
would not separate the lines either.

The idea that if you manually separate the "string" into sections and it works is not "weird" in fact lol it's logical .

You would need to write a function to do that leg work for you.

The problem is I'm trying to run this like a macro. I'm not sure on how to approach it with what you are suggesting.

##### Share on other sites

```\$iniR20 = iniread(@ScriptDir&"/b_set.ini", "2", "2", "")
Execute(\$iniR20)```

The ini looks like this:

```[2]

works perfectly. Thanks guys!

##### Share on other sites

This was my general idea Volly:

```\$sStrTest = "<B>More Information:</B><BR>&@CRLF&&nbsp;&nbsp;"
\$sTest = _StringExecuteMacro(\$sStrTest)
MsgBox(64, "Replaced: " & @extended, \$sTest)

Func _StringExecuteMacro(\$sString)
If StringInStr(\$sString, "@") = 0 Then Return SetExtended(0, \$sString)

Local \$strMacro = _StringMacroCreate()
Local \$aMacro = StringSplit(\$strMacro, ",")
Local \$nExtendedCount = 0
For \$iCC = 1 To \$aMacro[0]
\$sString = StringRegExpReplace(\$sString, \$aMacro[\$iCC] & "(?!:\w+)", Execute(\$aMacro[\$iCC]))
\$nExtendedCount += @extended
Next;\$iCC
Return SetExtended(\$nExtendedCount, \$sString)
EndFunc

Func _StringMacroCreate()
\$strMacro = "@AppDataCommonDir,@DesktopCommonDir,@DocumentsCommonDir"
\$strMacro &= ",@HomeDrive,@HomePath,@HomeShare,@LogonDNSDomain"
\$strMacro &= ",@LogonDomain,@LogonServer,@ProgramFilesDir,@CommonFilesDir"
\$strMacro &= ",@WindowsDir,@SystemDir,@TempDir,@ComSpec"
\$strMacro &= ",@Unicode,@AutoItUnicode,@compiled,@error"
\$strMacro &= ",@exitCode,@exitMethod,@extended,@NumParams"
\$strMacro &= ",@ScriptName,@ScriptDir,@ScriptFullPath,@ScriptLineNumber"
\$strMacro &= ",@WorkingDir,@AutoItExe,@AutoItPID,@AutoItVersion"
\$strMacro &= ",@GUI_CtrlId,@GUI_CtrlHandle,@GUI_DragID,@GUI_DragFile"
\$strMacro &= ",@GUI_DropID,@GUI_WinHandle,@HotKeyPressed,@SW_DISABLE"
\$strMacro &= ",@SW_ENABLE,@SW_HIDE,@SW_LOCK,@SW_MAXIMIZE"
\$strMacro &= ",@SW_MINIMIZE,@SW_RESTORE,@SW_SHOWDEFAULT,@SW_SHOWMAXIMIZED"
\$strMacro &= ",@SW_SHOWMINIMIZED,@SW_SHOWMINNOACTIVE,@SW_SHOWNA,@SW_SHOW"
\$strMacro &= ",@SW_SHOWNOACTIVATE,@SW_SHOWNORMAL,@SW_UNLOCK,@TRAY_ID"
\$strMacro &= ",@TrayIconFlashing,@TrayIconVisible,@CRLF,@CR"
\$strMacro &= ",@LF,@TAB,@KBLayout,@OSLang"
\$strMacro &= ",@OSType,@OSVersion,@OSBuild,@OSServicePack"
\$strMacro &= ",@DesktopWidth,@DesktopDepth,@DesktopRefresh,@SEC"
\$strMacro &= ",@MIN,@HOUR,@MDAY,@MON"
\$strMacro &= ",@YEAR,@WDAY,@YDAY"
Return \$strMacro
EndFunc```

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

##### Share on other sites

You can always use a sequence of characters (like @@) to represent @CRLF in the ini file - after you read the ini value you can easily replace @@ with @CRLF.

Just my 2 cents ...

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

##### Share on other sites

The solution Smoke came up with looks good. I'm going to file that one in my stash. Thanks!

## Create an account

Register a new account