Sign in to follow this  
Followers 0
failedtocompile

howto convert string from .ini to file path

4 posts in this topic

Hello people

just trying to work with IniRead(), more specifically retrieving data from the key and then using in conjunction with FileGetShortName()

currently it just outputs what is written in the ini file but i need it to interpret the string so it can be used with FileGetShortName()

My .ini

[file1]
path2=@ScriptDir & '\file\test.htm' ;just with this example i do not want to use exact UNC paths, also it is not translated in DOS properly if using 'file1\test.htm'

Have tried with no quotes around the path also.

my Script:

$filel1 = IniRead(@ScriptDir & '\guiconfig.ini', 'file1', 'path2', "")
$file1string = String ($file1)
$file1path = FileGetShortName($file1string)
MsgBox(0, "", $file1path)

any help would be appreciated

ftc

Share this post


Link to post
Share on other sites



It make no sense to have @ScriptDir macro in ini file but anyway, here a possibility:

$ini = IniRead(@ScriptDir & "\GUIConfig.ini", "file1", "path2", "Error")
If $ini <> "Error" Then
    $aTmp = StringSplit($ini, "&")
    $path = StringStripWS($aTmp[2], 7)
    $short = FileGetShortName(@ScriptDir & StringMid($path, 2, StringLen($path) - 2))
    ConsoleWrite($short & @CRLF)
Else
    ConsoleWrite($ini & @CRLF)
EndIf

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You want Execute.

$file1 = Execute(IniRead(@ScriptDir & '\guiconfig.ini', 'file1', 'path2', ""))
$file1path = FileGetShortName($file1)
MsgBox(0, "", $file1path)
Edited by AdmiralAlkex

Share this post


Link to post
Share on other sites

You want Execute.

$file1 = Execute(IniRead(@ScriptDir & '\guiconfig.ini', 'file1', 'path2', ""))
$file1path = FileGetShortName($file1)
MsgBox(0, "", $file1path)

danke AdmiralAlkex

that method worked.

I also came up with another method including the IniRead encapsulate into my Run(@ComSpec) which yielded similar results.

My Main Goal is to have almost all external calls configured from an ini file, so can modify the ini file instead of the code.

Thanks again to both for your help.

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