(to assign a record member name dynamically)
Guten Tag,
Ich suche Hilfe, um diesen Code zu vereinfachen und die aus der INI-Datei gelesenen Werte einer Variablen vom Typ "Datensatz" zuzuweisen, wobei sich der Elementname vom Schlüsselnamen in der INI-Datei unterscheidet. Ich habe nicht herausgefunden, wie ich den Mitgliedsnamen dynamisch zuweisen kann, da es zwei Gruppen (A und B) mit denselben Schlüsselnamen in der Datei, aber unterschiedlichen Namen im Datensatz gibt.
Code:
// ini file contains pairs key_name=value , the record contains abbreviated key name
if pars[0] = 'first_frame' then k := 'first_'+group else
if pars[0] = 'end_frame' then k := 'last_'+group else
if pars[0] = 'first_filename' then k := 'start_name_'+group else
if pars[0] = 'path' then
k := 'path_'+group else
if pars[0] = 'check_if_files_exist' then
k := 'check_files_exist_'+group;
if group = 'A' then
begin
if k = 'path_A' then
ini.basic.path_A := pars[1] else
if k = 'first_A' then
ini.basic.first_A := pars[1] else
if k = 'last_A' then
ini.basic.last_A := pars[1] else
if k = 'start_name_A' then
ini.basic.start_name_A := pars[1] else
if k = 'check_files_exist_A' then
ini.basic.check_files_exist_A := true;
end
else if group = 'B' then
begin
if k = 'path_B' then
ini.basic.path_B := pars[1] else
if k = 'first_B' then
ini.basic.first_B := pars[1] else
if k = 'last_B' then
ini.basic.last_B := pars[1] else
if k = 'start_name_B' then
ini.basic.start_name_B := pars[1] else
if k = 'check_files_exist_B' then
ini.basic.check_files_exist_B := true;
end;
end;
(English: Good morning,
I'm looking for help to simplify this code, assigning the values read from ini file to a variable of type Record, where the member name is different from the name of the key in the ini file. I haven't figured out how can I assign the member name dynamically because there are two groups (A and B) with the same key names in the file but different names in the record.)
Deklaration:
Code:
type TBasicSettings = record
is_scroll_vertical: boolean; scroll_type=vertical
is_image_direction_up: boolean;
is_search_colors_HSL: boolean;
path_A: string;
path_B: string;
check_files_exist_A: boolean;
check_files_exist_B: boolean;
RAM_disk: string;
RAM_free: LongWord;
start_name_A: string;first_filename
first_A: string;first_frame
last_A: string;end_frame=
start_name_B: string;first_filename
first_B: string;first_frame
last_B: string;end_frame
fps: byte;
scroll_max_shift: integer;
end;
basic.ini
[GENERAL]
Code:
[GENERAL]
scroll_type=vertical
image_direction=up
search_colors_in=
HSL
H_max_difference_deg=10%
S_max_difference_per=20%
L_max_difference_per=10%
;V_max_difference_per=10%
padding_left=22
padding_right=25
padding_top=0
padding_bottom=0
detect_max_character_count_on_screen=3
arrow_1_count=2
arrow_2_count=1
arrow_3_count=1
image_1_count=1
skip_detections_on_screen_when_frame_position_is_determined=1
group_to_copy_image_data_from=A
text_copy_color_direction=BA
RAM_disk=A:
RAM_disk_free_space=1GB