Помогите перевести код из javasript в delphi:
| Код | var global_stage // некрасивая глобальная переменная // bounds — массив [root, start, end] // tag_name — имя тега // остальные аргументы не указываем, используются для рекурсии function find_tags_in_subtree(bounds, tag_name, stage, second){ var root = bounds['root'] var start = bounds['start'] var end = bounds['end']
if(start == end) return [start]
if(!second) global_stage=stage
if(global_stage == 2) return [] if(!global_stage) global_stage = 0
tag_name = tag_name.toLowerCase()
var nodes=[] for(var node = root.firstChild; node; node = node.nextSibling){ if(node==start && global_stage==0){ global_stage = 1 } if(node.nodeName.toLowerCase() == tag_name && node.nodeName != '#text' || tag_name == ''){ if(global_stage == 1){ nodes.push(node) } } if(node==end && global_stage==1){ global_stage = 2 } nodes=nodes.concat(find_tags_in_subtree({root:node, start:start, end:end}, tag_name, global_stage, true)) } return nodes }
|
Пояснение: bounds у меня объявлен как:
| Код | type bounds=record root,sel_start,sel_end: IHTMLElement; end;
|
Помогите составить грамотный код, буду очень благодарен... |