For instance if the string was 84 characters in length and I wanted to divide it by 10. I would end of with this...
String = FFD8FFE000104A46494600010101006000600000FFDB0043000201010201010202020202020202030503
Result =
FFD8FFE000
104A464946
0001010100
6000600000
FFDB004300
0201010201
0102020202
0202020203
0503
Each line of characters is a variable.
This code works, but is there a better way?
Code: Select all
SplitStringVarByThisNumber = 10
Var := "FFD8FFE000104A46494600010101006000600000FFDB0043000201010201010202020202020202030503"
Len := StrLen(Var)
Sections := (Len / SplitStringVarByThisNumber)
Sections := ceil(Sections)
loop %Sections%
{
if A_index = 1
GetCharsStartingAt := (a_index)
if a_index = 2
GetCharsStartingAt := ((SplitStringVarByThisNumber) + 1)
if a_index > 2
GetCharsStartingAt := (((a_index - 1) * SplitStringVarByThisNumber) + 1)
NewStr%a_index% := SubStr(Var, GetCharsStartingAt , SplitStringVarByThisNumber)
}
Loop %Sections%
DisplayVar := DisplayVar "`n" . NewStr%a_index%
MsgBox %DisplayVar%