delphi - saving strings that are 'connected' and reading them and their 'connected' -
this not @ familiar with.
i want try make simple form 4 edit boxes, 2 @ top, 2 @ bottom, , button. want type couple of things in top 2 boxes related each other.
when have them both filled in click on button , saves information in database, preferable external file (doesn't have text, think better if not). can couple of times. saving edit fields database.
then when type 1 of words saved in 1 of edit fields @ bottom automatically types other word in last edit field. form should remember connect database every time it's opened when open time can still work edit fields.
can advise me on how this?
what looking known dictionary, if understand correctly. in other languages known associative array or hash.
you going want modern version of delphi, i'd guess 2010 or xe. if can't access you'd need 3rd party library, or home grown based off tstringlist
. in fact tstringlist
can operate in dictionary mode it's bit clunky.
you declare dictionary follows:
dict: tdictionary<string,string>;
you can add follows:
dict.add(box1.text, box2.text);
the first parameter key. second value. think of array indexed string rather integer.
if want recover value use:
dict[key];
in case write:
box4.text := dict[box3.text];
if want save file iterate on dict:
var item: tpair<string,string>; ... item in dict addtotextfile(item.key, item.value);
i've ignored error handling issues, dealing adding keys exist, asking keys not in dict, , on. should give flavour.
i'd recommend reading on associative arrays if aren't familiar them. i'm sure there page on wikipedia , worse read tutorial on python sure cover them – issues same no matter language consider.
Comments
Post a Comment