Forum > Beginners

[CLOSED] characters disapear splitting a string representing an array

(1/2) > >>

ratmalwer:
In a Database I have a string witch obviously represents an 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";}};} ---Tier||0,Tier|Insekte||1,Tier|Insekte|Biene||2,Pflanze||3,Pflanze|Blume||4,Pflanze|Blume|Zinnie||5
When I loop through the string to split the Words, I realize that the following characters disapear.


--- 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";}};} ---||0   ||1   ||2  ||3   ||4   ||5
Here an example how I  do that and gives the correct result.

--- 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";}};} ---    ende := Length(str);    for i := ende downto 1 do begin        if str[i] = ',' then begin           out := out + '<' + copy(str,i+1,ende -i);           ende := i-1;        end;        if i = 1 then begin           out := out + '<' + copy(str,0,ende);        end;    end;    showmessage('out: ' + out);    
So I think there is a hidden arrayfunction.

Before I go on I want to assure whats going on. Maybe I cold take further advantage going on with this project.
Is there a documentation of that availabe?

Postscriptum:
I just found that the removal must take place earliey by moving the value to my str....

Bart:
Exactly how do you want the output to be, given the inputstring in the example?

Bart

ratmalwer:
Hi Bart

just realiyzed the effect happens on the way from DB to my string.
actually I wanted to delete this question until I foud out more myself, but it  cannot be deleted.  :o

Bart:
You can lock the topic IIRC.
Or you can edit your first post and edit the subjectline to something like "[CLOSED] characters disapear splitting a string representing an array"

Bart

wp:

--- Quote from: ratmalwer on November 27, 2021, 05:28:43 pm ---In a Database I have a string witch obviously represents an 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";}};} ---Tier||0,Tier|Insekte||1,Tier|Insekte|Biene||2,Pflanze||3,Pflanze|Blume||4,Pflanze|Blume|Zinnie||5
--- End quote ---
I don't think that this is a simple array, it looks more like a tree

--- Code: ---Tier
  Insekte
    Biene
Pflanze
  Blume
    Zinnie
--- End code ---

The syntax for each tree element ("node") is
  <node1>|<node2>|...|<last node>||<index of last nade>

The comma separates these paths. The single '|' separates the nodes. Double '||' is the end of a branch of nodes. The number is the index of the end node.

You can use a TTreeView to display this hierarchical information in a tree.

Navigation

[0] Message Index

[#] Next page

Go to full version