twenty_sleven Posted February 12, 2012 Share Posted February 12, 2012 (edited) program Sandbox; var i,k,j : Integer; aStrings: array of string; sUserInput: String; begin aStrings := ['','','','','','','','','','','','','']; sUserInput := 'Close all applications '; sUserInput := Uppercase(sUserInput); k := 0; j := 0; //j acts as previous space, k is the current value of the Array we're on for i:= 1 to Length(sUserInput) - 1 do if StrGet(sUserInput,i) = ' ' then aStrings[k] := copy(sUserInput, j, i+1); j := i; k := k+1; WriteLn(aStrings[k-1]); end. end. Program to break apart a string, and then put it's separate parts into separate values in an array. This program outputs "CLOSE ALL APPLICATIO" while I was hoping for... "CLOSE" "ALL" "APPLICATIONS" It seems like the for loop executes all 22 "loops" on the first line of code, I'd like to make that also apply to j := i; & k := k+1; :::EDIT::: Sorry, fixed the problem with the "Explode" function. Edited February 12, 2012 by twenty_sleven Quote Link to comment Share on other sites More sharing options...
FHannes Posted February 12, 2012 Share Posted February 12, 2012 [scar]program Sandbox; var I, L: Integer; aStrings: TStringArray; sUserInput: string; begin sUserInput := 'Close all applications '; sUserInput := Uppercase(sUserInput); aStrings := Explode(' ', sUserInput); L := Length(aStrings); for I := 0 to L - 1 do WriteLn(aStrings); end.[/scar] Sometimes the solution is just [wiki=Explode]that easy[/wiki]. Quote Link to comment Share on other sites More sharing options...