Forum > General

How can i find (or select ) Array with name??

(1/5) > >>

majid.ebru:
Hi

i have many array like these :

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---const  //----- Verb 2 ----------------  {V01 = Verb 1 ___ 11 = Group 11 ___ 11 = + ___ 12 = -}  V021111 : array[0..02] of String = ('V17','V08','V19');  V021112 : array[0..03] of String = ('V10','V17','V08','V19');  V021121 : array[0..02] of String = ('V08','V09','V19');  V021122 : array[0..03] of String = ('V10','V08','V09','V19');  V021131 : array[0..02] of String = ('V30','V08','V09');  V021132 : array[0..03] of String = ('V10','S21','V08','V09');//-------------  V021211 : array[0..03] of String = ('V08','V17','V12','V19');  V021212 : array[0..04] of String = ('V08','V10','V17','V12','V19');  V021221 : array[0..02] of String = ('V08','V09','V19');  V021222 : array[0..03] of String = ('V08','V10','V09','V19');  V021231 : array[0..02] of String = ('V08','S21','V09');  V021232 : array[0..03] of String = ('V08','V10','S21','V09');//-------------  V021311 : array[0..02] of String = ('V08','V12','V19');  V021312 : array[0..03] of String = ('V08','V10','V12','V19');  V021321 : array[0..02] of String = ('V08','V09','V19');  V021322 : array[0..03] of String = ('V08','V10','V09','V19');  V021331 : array[0..02] of String = ('V08','S21','V09');  V021332 : array[0..03] of String = ('V08','V10','S21','V09');//--------------------   
then i get name of array :

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---tAry[0] :=  P1_E_3.Text + P1_E_2.Text; // --->  like : V021322 
then i should send same array to my function "Find_DB('2',....)" :

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---      case(tAry[0])of        'V021111': tAry[0] := Find_DB('2',V02_11_11);        'V021112': tAry[0] := Find_DB('2',V02_11_12);        'V021121': tAry[0] := Find_DB('2',V02_11_21);        'V021122': tAry[0] := Find_DB('2',V02_11_22);        'V021131': tAry[0] := Find_DB('2',V02_11_31);        'V021132': tAry[0] := Find_DB('2',V02_11_32);        'V021211': tAry[0] := Find_DB('2',V02_12_11);        'V021212': tAry[0] := Find_DB('2',V02_12_12);        'V021221': tAry[0] := Find_DB('2',V02_12_21);        'V021222': tAry[0] := Find_DB('2',V02_12_22);        'V021231': tAry[0] := Find_DB('2',V02_12_31);        'V021232': tAry[0] := Find_DB('2',V02_12_32);        'V021311': tAry[0] := Find_DB('2',V02_13_11);        'V021312': tAry[0] := Find_DB('2',V02_13_12);        'V021321': tAry[0] := Find_DB('2',V02_13_21);        'V021322': tAry[0] := Find_DB('2',V02_13_22);        'V021331': tAry[0] := Find_DB('2',V02_13_31);        'V021332': tAry[0] := Find_DB('2',V02_13_32);        else ShowMessage('Error- U277');      end;  

i know this is mistek,but i need same that:



--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---findcomponent('V02_13_32')as array //   this is misteck, I know 
can anybody help or guide me how can i select array with name

ASerge:

--- Quote from: majid.ebru on January 15, 2019, 06:06:21 am ---can anybody help or guide me how can i select array with name

--- End quote ---
The most flexible option would be to use an external file. But it will require a thorough check of its structure when loading.
If this option does not appeal, you can add references to arrays in TStringList with the desired names and look for them there. The list can be sorted.

majid.ebru:

--- Quote from: ASerge on January 15, 2019, 07:04:31 am ---The most flexible option would be to use an external file

--- End quote ---

How can i ?


--- Quote from: ASerge on January 15, 2019, 07:04:31 am ---you can add references to arrays in TStringList with the desired names and look for them there. The list can be sorted.

--- End quote ---

can you show me one example or one link about that?

Handoko:
I can't understand your explanation. Can you provide some examples data for the inputs and what are the outputs?

lucamar:

--- Quote from: majid.ebru on January 15, 2019, 11:24:34 am ---
--- Quote from: ASerge on January 15, 2019, 07:04:31 am ---The most flexible option would be to use an external file

--- End quote ---

How can i ?

--- End quote ---

Instead of using constants write a file with lines like, p.e.:
    V021212=V08 V10 V17 V12 V19

You can read this file as an INI file (see p.e. Using INI files) and build your arrays at run-time with the help of a TStrings descendant, using TStrings.DelimitedText

And this is just one option: following on the preceding idea you may use instead an INI file with sections such as:

--- Code: ---[V021212]
Item0=V08
Item1=V10
Item2=V17
Item3=V12
Item4=V19
--- End code ---
reading each section as needed with TIniFile.ReadSectionValues or TIniFile.ReadString and building your arrays on the fly.

Read the FCL docs for more info.

Navigation

[0] Message Index

[#] Next page

Go to full version