Note that there are some explanatory texts on larger screens.

plurals
  1. POWho can help me to convert this small PHP code to Delphi?
    primarykey
    data
    text
    <p><b>Hello everybody,</b></p> <p>I have a small code in PHP that I would like to convert in Delphi and I have some troubles...<br> Here is the PHP code :</p> <pre><code>$from = "121.198.0.0"; $to = "121.198.255.255"; $arry1 = explode(".", $from); $arry2 = explode(".", $to); $a1 = $arry1[0]; $b1 = $arry1[1]; $c1 = $arry1[2]; $d1 = $arry1[3]; $a2 = $arry2[0]; $b2 = $arry2[1]; $c2 = $arry2[2]; $d2 = $arry2[3]; while ($d2 &gt;= $d1 || $c2 &gt; $c1 || $b2 &gt; $b1 || $a2 &gt; $a1) { if ($d1 &gt; 255) { $d1 = 1; $c1++; } if ($c1 &gt; 255) { $c1 = 1; $b1++; } if ($b1 &gt; 255) { $b1 = 1; $a1++; } echo "$a1.$b1.$c1.$d1&lt;br&gt;"; $d1++; } </code></pre> <p>And in Delphi I started with that :</p> <pre><code>procedure TForm1.Button1Click(Sender: TObject); var Arry1, Arry2: TStringList; RangeFrom, RangeTo: string; a1, b1, c1, d1, a2, b2, c2, d2: string; begin RangeFrom := Edit1.Text; RangeTo := Edit2.Text; Arry1 := Explode('.', RangeFrom); Arry2 := Explode('.', RangeTo); a1 := Arry1[0]; b1 := Arry1[1]; c1 := Arry1[2]; d1 := Arry1[3]; a2 := Arry1[0]; b2 := Arry1[1]; c2 := Arry1[2]; d2 := Arry1[3]; while (StrToInt(d2) &gt;= StrToInt(d1)) //and StrToInt(c2) &gt; (StrToInt(c1) //and StrToInt(b2) &gt; (StrToInt(b1) //and StrToInt(a2) &gt; (StrToInt(a1) do begin if (StrToInt(d1) &gt; 255) then begin d1 := '1'; StrToInt(c1)+1; end; if (StrToInt(c1) &gt; 255) then begin c1 := '1'; StrToInt(b1)+1; end; if (StrToInt(b1) &gt; 255) then begin b1 := '1'; StrToInt(a1)+1; end; ListBox1.Items.Add(a1+'.'+b1+'.'+c1+'.'+d1); StrToInt(d1)+1; end; end; </code></pre> <p>(For the Explode function, I use : <a href="http://www.marcosdellantonio.net/2007/06/14/funcao-explode-do-php-em-delphi/" rel="nofollow">http://www.marcosdellantonio.net/2007/06/14/funcao-explode-do-php-em-delphi/</a>)</p> <p>Someone can help me to make working this small code in Delphi ?</p> <p>Thanks in advance :)</p> <p>Beny</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload