delphi - How to get last string in TStringList -


i've been searching days on how this, , nothing need (or don't understand how implement solution).

what need parse string, street address, tstringlist, , set strings list variables can pass rest of program. have list working ok:

var addresslist : tstringlist; : integer;  begin addresslist := tstringlist.create; addresslist.delimiter := ' '; addresslist.delimitedtext := rawaddressstr; //rawaddressstr parsed file , string result '1234 dark souls lane wyoming, mi 48419'  := 0 addresslist.count-1    addresslist.strings[i]; //not sure here 

the issue address isn't same length. address '1234 dark souls 2 lane wyoming...' or '1234 dark lane wyoming...'

so need able use tstringlist set zip, state , city variables later use. use tstringlist.find, zip code isn't same. there way last string , go backwards there? (going backwards because once city, state zip can remove rawaddressstr , set rest address string.)

thanks.

edit, here's code needed (thanks below comments): addresslist := tstringlist.create;

addresslist.delimiter := ' '; addresslist.delimitedtext := rawaddressstr;  := 0 addresslist.count-1   lastindex := addresslist.count - 1;   zipstr := addresslist[lastindex];   statestr := addresslist[lastindex - 1];   citystr := addresslist[lastindex - 2]; 

now can use these stringreplace take out city, state zip full address string, , set address string use.

i little bit unsure of you're looking since ask of how last string of stringlist, @ end of question ask

is there way last string , go backwards there?

if want last string of stringlist can use

  var addresslist : tstringlist;       mystring: string; begin   mystring := addresslist.last; //this...   mystring := addresslist.strings[addresslist.count-1]; //...and same thing end; 

if for-loop in reverse or backwards should write:

for := addresslist.count-1 downto 0   addresslist.strings[i]; //not sure here 

notice says "downto" , not "to".

now, if stop @ specific string, lets zip code, need make software understand reading.

which 1 of delimited strings city? 1 address? software, string string, doesn't know, or care reading.

so suggest have database of citys can compare strings of addresslist t,o , see if there match.

you implement logic in algorithm. if know last string of delimited adresslist string city-name, know have city name right there can use.

if know between zip code , city name street address, copy between zip , city-name , use street-name information.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -