Jump to content

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;
Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

  • Moderators

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Ë­{¥
+·jëÊ·ö·¶×¦¦Ø§ÚÅç.µëayéí·¬¶¸§br¾*.²¢²}ýµ©ÚºÚ"µÊ&©Ýjëh×6$sStrTest = "<B>More Information:</B><BR>'&@CRLF&'&nbsp;&nbsp;"
_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.

Link to comment
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?

Link to comment
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.
Link to comment
Share on other sites

  • Moderators

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 &= ",@FavoritesCommonDir,@ProgramsCommonDir,@StartMenuCommonDir,@StartupCommonDir"
    $strMacro &= ",@AppDataDir,@DesktopDir,@MyDocumentsDir,@FavoritesDir"
    $strMacro &= ",@ProgramsDir,@StartMenuDir,@StartupDir,@UserProfileDir"
    $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 &= ",@AutoItX64,@InetGetActive,@InetGetBytesRead,@COM_EventObj"
    $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 &= ",@ProcessorArch,@ComputerName,@UserName,@IPAddress1"
    $strMacro &= ",@IPAddress2,@IPAddress3,@IPAddress4,@DesktopHeight"
    $strMacro &= ",@DesktopWidth,@DesktopDepth,@DesktopRefresh,@SEC"
    $strMacro &= ",@MIN,@HOUR,@MDAY,@MON"
    $strMacro &= ",@YEAR,@WDAY,@YDAY"
    Return $strMacro
EndFunc

Edited by SmOke_N
Had a variable incorrect

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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...