Latest Articles
 by awuehr on 11-10-2008 in Tips & Tricks by Village Idiot on 11-04-2008 in Classes & Objects by codefreek on 10-23-2008 in Basic by wiifanatic on 09-12-2008 in Security & Permissions by drewbee on 07-03-2008 in Tips & Tricks
 IRC Channel
 Join the friendly bunch on IRC... (#TalkPHP on Freenode) ...Also available via a web interface. See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
 Associates
 Associates
 TalkPHP » Need delphi to PHP translation
 06-29-2009, 09:25 PM #1 (permalink) Wizard       Join Date: Sep 2007 Posts: 1,299 Thanks: 17 Need delphi to PHP translation I know thisi s the python to PHP forum, but delphi always reminds me of python so here it goes. I found this script at random on the interweb and want to see what it does in PHP. Translation. Now. Function GenStr(MaxLen,Restrictions:Integer):String;Overloa d; {Possible Resctiction Values: 1 - All 2 - Just Letters and Numbers 3 - Just Numbers 4 - Just Letters } Var St:Byte; Total:String; begin Repeat Randomize; St := Random(255); If Restrictions = 1 then Total := Total + chr(St); If Restrictions = 2 then If (St >= 48) and (St <= 57) or (St >= 65) and (St <= 90) or (St >= 97) and (St <= 122) then Total := Total + chr(St); If Restrictions = 3 then If (St >= 48) and (St <= 57) then Total := Total + chr(St); If Restrictions = 4 then If (St >= 65) and (St <= 90) or (St >= 97) and (St <= 122) then Total := Total + chr(St); Until Length(Total) = MaxLen; Result := Total; end; Function GenStr(MaxLen:Integer;Pattern:String):String;Overl oad; {Possible Resctiction Values: 1 - All 2 - Just Letters and Numbers 3 - Just Numbers 4 - Just Letters Possble Pattern Parameters: A or a - All L - Letter In Capitals l - Letter not in capitals C or c - Character ( A,B or a,b (etc.)) N or n - Numbers R or r - Random Generated Pattern Ex: If u wanted a generated string that was Number, number,number,Captiol letter then any letter, u would use this pattern: NNNLC or NNNLc } Var St:Byte; Total:String; Ptrn:String; P:Byte; PtrnCount:Integer; begin If (Pattern = 'R') or (Pattern = 'r') then Begin repeat Randomize; P := Random(225); Case P of 65 or 97:Ptrn := Ptrn + 'A'; 78:Ptrn := Ptrn + 'L'; 108:Ptrn := Ptrn + 'l'; 67 or 99:Ptrn := Ptrn + 'C'; 78 or 110:Ptrn := Ptrn + 'N'; end; until Length(Ptrn) = (MaxLen div 2) + 1; Pattern := Ptrn; end; PtrnCount := 0; Repeat Randomize; Inc(PtrnCount); If (Pattern[PtrnCount] = 'A') or (Pattern[PtrnCount] = 'a') then Total := Total + chr(Random(255)); If (Pattern[PtrnCount] = 'L') then Begin Repeat St := Random(255); Until (St >= 65) and (St <= 90); Total := Total + chr(St); end; If (Pattern[PtrnCount] = 'l') then Begin Repeat St := Random(255); Until (St >= 97) and (St <= 122); Total := Total + chr(St); end; If (Pattern[PtrnCount] = 'C') or (Pattern[PtrnCount] = 'c') then begin Repeat St := Random(255); Until (St >= 65) and (St <= 90) or (St >= 97) and (St <= 122); Total := Total + chr(St); end; If (Pattern[PtrnCount] = 'N') or (Pattern[PtrnCount] = 'n') then begin Repeat St := Random(255); Until (St >= 48) and (St <= 57); Total := Total + chr(St); end; If PtrnCount = Length(Pattern) then PtrnCount := 0; Until Length(Total) = MaxLen; Result := Total; end; Wildhoney Green power infraction was added to this post, Village Idiot = lost 10 hp.. Behave! :) __________________ Last edited by codefreek : 06-30-2009 at 02:10 AM.
 06-29-2009, 10:07 PM #2 (permalink) The Addict     Join Date: Jun 2008 Posts: 335 Thanks: 2 LOL ( Char limit ) __________________ My Blog
 06-29-2009, 10:12 PM #3 (permalink) La Vida es Sueño        Join Date: Sep 2007 Location: Oldham Posts: 2,283 Thanks: 90 WRONG FORUM! Salathe! Codefreek! Hand out the infraction! __________________ The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
 06-29-2009, 10:13 PM #4 (permalink) The Prestige        Join Date: Sep 2007 Location: Sweden, Stockholm Posts: 1,080 Thanks: 115 Wildhoney; You are the green, mean, banmachine, so you infract him __________________
The Prestige

Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32

Quote:
 Wildhoney; You are the green, mean, banmachine, so you infract him
Don't provoke him! He gets violent!
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)

 06-29-2009, 10:34 PM #6 (permalink) La Vida es Sueño        Join Date: Sep 2007 Location: Oldham Posts: 2,283 Thanks: 90 __________________ The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Wizard

Join Date: Sep 2007
Posts: 1,299
Thanks: 17

Quote:
 Originally Posted by Wildhoney WRONG FORUM! Salathe! Codefreek! Hand out the infraction!
Quote:
 Originally Posted by Tanax Wildhoney; You are the green, mean, banmachine, so you infract him
Relax, I can add infractions. Oh, wait....
__________________

 06-30-2009, 02:12 AM #8 (permalink) Super Moderator       Join Date: Sep 2007 Location: Near you. Posts: 791 Thanks: 241 i gave him the Wildhoney Green power infraction. ;) PS: please format your code xD __________________ Codefreek's - News Letter, Tech, & some random ramblings
The Prestige

Join Date: Dec 2007
Posts: 1,045
Thanks: 193

Quote:
 Originally Posted by Enfernikus LOL ( Char limit )
this ( this aswell )
__________________
"The reasonable man adapts himself to the conditions that surround him... The unreasonable man adapts surrounding conditions to himself... All progress depends on the unreasonable man." - George Bernard Shaw

 07-10-2009, 01:51 PM #10 (permalink) The Wanderer   Join Date: May 2009 Location: Lincoln Posts: 9 Thanks: 0 I 'eated' your code tags
 06-25-2012, 12:34 PM #11 (permalink) The Wanderer   Join Date: May 2012 Location: usa Posts: 6 Thanks: 0 Nike NFL Jerseys from china, Nike NFL Jerseys online,cheap Nike NFL Jerseys,2012 nike nfl jerseys, nike nfl women jerseys,buy jerseys online, soccer jerseys shop online, nfl jerseys store online

 Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On

 Similar Threads Thread Thread Starter Forum Replies Last Post Can't get PHP 5. to work? Newbie windows PHP guy DotNetTim Absolute Beginners 11 02-01-2013 11:02 AM 10 PHP Myths Dispelled Wildhoney General 9 06-15-2009 06:55 AM Tutorial for Beginners - Not a usual tutorial [Read it all and i think it will help] codefreek Absolute Beginners 8 01-26-2009 03:14 AM PHP Compressor Kalle Script Giveaway 8 05-28-2008 12:14 AM what are all the subjects in php? sarmenhb General 7 01-21-2008 05:41 PM

All times are GMT. The time now is 03:28 AM.