So I have a text file that contain:
key1=value1
key2=value2
key3=value3
I want to create a function that return value for key I'm searching for.
I'm not really need this because I already have my code working great, but I wonder and keen to learning another ways to do it
I believe there must be a dozen ways to do this with less lines of codes and in higher processing speed compared to my stupid and simple code.
Func ReadTextFileBaseOnKey($fFile, $sKey) $iLine = 1 $sResult = "" $file = fileOPen($fFile, 0) while 1 $sRead2 = FileReadLine($file, $iLine) if @error Then FileClose($file) ExitLoop Else $sRead = FileReadLine($fFile, $iLine) If StringLeft($sRead, StringLen($sKey)) = $sKey then $sResult = StringRight($sRead, StringLen($sRead)-StringInStr($sRead,"=",0)) ExitLoop EndIf $iLine = $iLine + 1 EndIf WEnd FileClose($file) Return $sResult EndFunc