An example!
First MsgBox shows that StringSplit works as desired.
The second MsgBox shows that StringSplit has not emptied any indexed variables.
Code: Select all
String = "art_id";"art_name2";"trade_mark";"art_info3"
StringSplit Field_, String, %A_Space%`;`r`n, "
MsgBox 64, Rad %A_LineNumber% -> %A_ScriptName%, % "( " String " )`n`nField_0 .: " Field_0 "`nField_1 .: " Field_1 "`nField_2 .: " Field_2 "`nField_3 .: " Field_3 "`nField_4 .: " Field_4 "`nField_5 .: " Field_5
String =
StringSplit Field_, String, %A_Space%`;`r`n, "
MsgBox 64, Rad %A_LineNumber% -> %A_ScriptName%, % "( " String " )`n`nField_0 .: " Field_0 "`nField_1 .: " Field_1 "`nField_2 .: " Field_2 "`nField_3 .: " Field_3 "`nField_4 .: " Field_4 "`nField_5 .: " Field_5
(I don't know if the input string have 0, 2, 5 or 72 fields)
Right now, maybe the only solution is to empty the variables with a Loop before StringSplit
Code: Select all
Loop 2
{ Loop % Field_0 ; Clear Indexed fields!
Field_%A_Index% =
String = "art_id";"art_name2";"trade_mark";"art_info3"
StringSplit Field_, String, %A_Space%`;`r`n, "
MsgBox 64, Rad %A_LineNumber% -> %A_ScriptName%, % "( " String " )`n`nField_0 .: " Field_0 "`nField_1 .: " Field_1 "`nField_2 .: " Field_2 "`nField_3 .: " Field_3 "`nField_4 .: " Field_4 "`nField_5 .: " Field_5
Loop % Field_0 ; Clear Indexed fields!
Field_%A_Index% =
String =
StringSplit Field_, String, %A_Space%`;`r`n, "
MsgBox 64, Rad %A_LineNumber% -> %A_ScriptName%, % "( " String " )`n`nField_0 .: " Field_0 "`nField_1 .: " Field_1 "`nField_2 .: " Field_2 "`nField_3 .: " Field_3 "`nField_4 .: " Field_4 "`nField_5 .: " Field_5
}
ExitApp
ESC::
ExitApp
Return
Would other instructions work better than StringSplit in my case?
(I think about, if Object would be a better solution, but at the moment, I think the structure would be more complicated.)