cannaper Posted June 20, 2014 Posted June 20, 2014 (edited) Hi i have following array: Now i want to check Pseudo code: StringInStr salutation === firstname then Replace the Firstname in Salutation with nothing example: Salutation: Hall Herr Albeck After replace Hallo Herr, same with lastname Current Code its half working but only for one firstname or lastname and not together expandcollapse popupFunc Main() Local $sAdr = @ScriptDir & "/rsg_mailing.csv" Local $h = FileOpen($sAdr, 0) Local $aRet = _CSV2Array($h, Default, True, 1) FileClose($h) _ArrayDisplay($aRet) For $i = 0 To UBound($aRet) - 2 $i = $i + 1 ;Bekomme Vorname $checkFirstName = $aRet[$i][1] $lastName = $aRet[$i][2] ;Salutation $salutation = $aRet[$i][3] If (StringInStr($salutation, $lastName)) Then $test = StringReplace($aRet[$i][3], $lastName, "") ;Replace Lastname with nothing $aRet[$i][3] = $test ConsoleWrite($test & @LF) EndIf If (StringInStr($salutation, $checkFirstName)) Then $replacefirstName = StringReplace($aRet[$i][3], $checkFirstName, "") $aRet[$i][3] = $replacefirstName ConsoleWrite($replacefirstName & @LF) EndIf ;ConsoleWrite($checkFirstName & @LF) Next _ArrayDisplay($aRet) EndFunc ;==>Main ouput from this code: greetings Edited June 20, 2014 by cannaper
Solution czardas Posted June 20, 2014 Solution Posted June 20, 2014 (edited) It looks to be working to me. I can't test it on the system I'm on right now. Why are you adding 1 to $i? $i = $i +1 Do you really intend to skip past every other row? Edited June 20, 2014 by czardas operator64 ArrayWorkshop
cannaper Posted June 20, 2014 Author Posted June 20, 2014 thx i removed the +1 now its woring! idk why i added this xD czardas 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now