Subj : RE: [Developers] Replacing Text
To   : All
From : Robert Wolfe
Date : Fri Jan 11 2019 04:31 pm

Sharing this message with those who may be interested:

                    -------- Forwarded Message ---------
Original: DATE..... 11 Jan 2019,  04:19p
Original: FROM..... [email protected]
Original: TO....... ROBERT WOLFE
Original: SUBJECT.. RE: [Developers] Replacing Text
Original: FORUM.... Private Email

On Jan 11, 2019 05:01am, [email protected] wrote to ROBERT WOLFE:

> Hi

> This maybe a simple question but not sure of the best way to do it.

> I have a variable - for example say it contains "Mr John Smith"
> I need to change this variable to = "Mr%20John%20Smith"
> So basicially finding a space and replacing it with %20

> Can anyone suggest the best way to do this ?

Dave, I believe something like this might help you out for a starting point:

//
// Will search for a spaces in a string and replace it with %20/
// Coded by Robert Wolfe <[email protected]>
//

#include "util.wch"
#include "cmdline.wch"

if (GetNode() = 0) then
   LoginSystem()
end if

dim string1 as string = "Mr. John Doe, Sr."
dim string2 as string = ""
dim char as string = ""
dim index as integer = 0

for index = 1 to len(string1)
   char = mid(string1, index, 1)
   if char = " " then char = "%20"
   string2 = string2 + char
next index

print "string1 = "; string1
print "string2 = "; string2

When run using 'wcrun.exe -r' the code yields the following:

string1 = Mr. John Doe, Sr.
string2 = Mr.%20John%20Doe,%20Sr.

As a sidenote, I always include the LoginSystem() routine in all of my
programs so that I am not forced to log into the BBS when I want to run the
WCX outside of the BBS.  Hope this helps.

... Platinum Xpress & Wildcat!..... Nice!!!!



-!-------------------------------------------------------------------
To unsubscribe, send e-mail to [email protected] with
UNSUBSCRIBE Developers in the message body on a line by itself.
To contact the list admin, e-mail [email protected]
-!-------------------------------------------------------------------



                    ----- End of Forwarded Message -----

... Platinum Xpress & Wildcat!..... Nice!!!!
--- Platinum Xpress/Win/WINServer v3.0pr5
* Origin: Omicron Theta (1:116/17)