SRL Archive - OSR Help

Conversion


Master BAW

2012-06-22 18:04:15

How to make this:
SELECT%20name%20FROM%20items%20WHERE%20id%20=%201

from this:
SELECT name FROM items WHERE id = 1

How to convert spaces to %20? I need this for connecting with my database because else it won't work. :)

x[Warrior]x3500

2012-06-22 18:16:37

ctrl+r -> add a space char to the first textbox -> add %20 to second text box -> replace all

Master BAW

2012-06-22 18:24:00

From: x[Warrior]x3500
ctrl+r -> add a space char to the first textbox -> add %20 to second text box -> replace all


that's not what I mean lol :)
I mean how to do it in a function, because I don't want the script look so messy.

x[Warrior]x3500

2012-06-22 18:27:38

get a string of whatever you will send to your database, and before you send it, use the replace(); function (or replaceWrap(); )

Master BAW

2012-06-22 19:59:37

Can you please give an example, I try it but I don't understand the last thing you have to put in….


program New;
{$i SRL\SRL.simba} // includes all main functions


var
Q,R : string;
F : TReplaceFlags;

begin

SetupSRL; // essential function to make bots work

Q := 'Test Test Test Test';


//R := Replace(Q,' ','20',F);
R := ReplaceWrap(Q,' ','%20',F);

writeln(R);

end.

it only replaces it once… :S

x[Warrior]x3500

2012-06-22 20:19:43


program new;
{$I SRL/SRL.simba}
var
Q,R,D : string;
F : TReplaceFlags;

begin
setupsrl;

Q := 'Test Test Test Test';

D := ReplaceWrap(Q,' ','%20',F);
while(D<>R)do
begin
R:= D;
D := ReplaceWrap(D,' ','%20',F);
end;

writeln(R);
end.

Brandon

2012-06-22 20:21:40

No need for all that.


ReplaceRegExpr('%20', 'SELECT%20name%20FROM%20items%20WHERE%20id%20=%201', ' ', True)

I'll finish my RegEx tutorial eventually. 20 Lines turns into 1.