Jump to content

question about iniEx UDF


Recommended Posts

hello sirs,
i have searched allot about an function that can  read the INI file as a  string

i mean function to read the ini files from string and not from the file directly.

i finally found an UDF that do what i want

but unfortunately all the functions work,  but the function that i want it not working.

this is the udf

the function that  i need is _IniReadFromString

this is the function

Func _IniReadFromString($szInput, $szSection, $szKey, $Default)
$szInput = StringStripCR($szInput)
Local $aRegMl = StringRegExp($szInput, "\[" & __StringEscapeRegExp($szSection) & "\]\n+(?:[^\[].*?=.*\n)*" & __StringEscapeRegExp($szKey) & "=(.*)\n?(", 3)
If @error Then Return SetError(1, 0, $Default) ; key not found
    Return $aRegMl[0]
EndFunc;==>_IniReadFromString

i hope that any one can help me

thank you in advance

iniex.au3

Link to comment
Share on other sites

32 minutes ago, nacerbaaziz said:

but unfortunately all the functions work,  but the function that i want it not working.

 

Might be a good idea to tell everyone what's not working, and how.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

What is wrong with the INI functions built into AutoIt, such as IniRead()?

Link to comment
Share on other sites

5 minutes ago, TheXman said:

What is wrong with the INI functions built into AutoIt, such as IniRead()?

I WANT TO READ AN INI SECTION FROM MY WEB SITE, AND I DON't want to create an ini file into the user PCS because the their is an some web site information such as the ftp password, for that i want to read the section with out the creation of the ini file.

Link to comment
Share on other sites

There is an error in the function's regular expression.  Right before the last double quote, there is an erroneous right paren ("(").  The corrected function below has the original line commented out and the corrected line right below it.

Func _IniReadFromString($szInput, $szSection, $szKey, $Default)
    $szInput = StringStripCR($szInput)
;~  Local $aRegMl = StringRegExp($szInput, "\[" & __StringEscapeRegExp($szSection) & "\]\n+(?:[^\[].*?=.*\n)*" & __StringEscapeRegExp($szKey) & "=(.*)\n?(", 3)
    Local $aRegMl = StringRegExp($szInput, "\[" & __StringEscapeRegExp($szSection) & "\]\n+(?:[^\[].*?=.*\n)*" & __StringEscapeRegExp($szKey) & "=(.*)\n?", 3)
    If @error Then Return SetError(1, 0, $Default) ; key not found

    Return $aRegMl[0]
EndFunc ;==>_IniReadFromString

 

By the way, think twice before replying in all caps when someone is trying to help you.  The next time you do it, don't be surprised if you get no replies.   :naughty:

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

×
×
  • Create New...