I just learned that I can use ExecuteFile> on a url to launch a web page and this would make my code a lot simpler, but how do I put a % symbol in that string without the system assuming its marking a variable?
Previously i was opening a web page by launching the browser, clicking the url line, and "sendtext" to output the address. I wasn't clear on how to use a % outside of notating a variable so when I needed the symbol, i just had a line sending just the % symbol, and the next line would output the next portion of the URL.
Even tried making a variable that would result in a percent symbol but I wasn't successful in making that work. (example Let>percent=%
Let>URL=www.somesite.com/parameter1%percent%par ... parameter3 but that didn't work for reasons that are hopefully obvious to you (and frustrating to me)
Thanks everyone and anyone willing to help me get a clue
Mitch
Opening a URL containing a % symbol
Moderators: Dorian (MJT support), JRL
- Dorian (MJT support)
- Automation Wizard
- Posts: 1378
- Joined: Sun Nov 03, 2002 3:19 am
- Contact:
Re: Opening a URL containing a % symbol
I've put together a few examples of using ExecuteFile with URLs containing a %. Hopefully this will give you an idea of how to get around your issue.
Code: Select all
//This works
executefile>https://www.bing.com/search?q=%something
//This works
executefile>https://www.bing.com/search?q=%hello%
//This works
executefile>https://www.bing.com/search?q=%25&%parm%
//It gets more complicated when we add variables
//This doesn't work if there's already a % symbol in the URL...
let>parm=hello
executefile>https://www.bing.com/search?q=%25&%parm%
//..it does if there isn't a %, but of course removes the %
let>parm=hello
executefile>https://www.bing.com/search?q=25&%parm%
//..this works though
let>parm=%hello%
executefile>https://www.bing.com/search?q=25&%parm%
//..but then breaks if there a % in the url
let>parm=%hello%
executefile>https://www.bing.com/search?q=%25&%parm%
//..so we can do this instead
let>parm=%hello%
let>percent=%
executefile>https://www.bing.com/search?q=%percent%25&%parm%
//..adding some more
let>parm=%hello%
let>percent=%
executefile>https://www.bing.com/search?q=%percent%25&%parm%%percent%something%percent%somethingelse%percent%%percent%
//..or just this
let>percent=%
executefile>https://www.bing.com/search?q=%percent%
Yes, we have a Custom Scripting Service. Message me or go here
Re: Opening a URL containing a % symbol
Thank you so much. I will put this to good use.
Re: Opening a URL containing a % symbol
Another option is to use VBA functions (like below) to code/decode the URL and pass it on to execute file command
Code Couresty of http://www.freevbcode.com/ShowCode.asp?ID=1512
Code Couresty of http://www.freevbcode.com/ShowCode.asp?ID=1512
Code: Select all
Public Function URLEncode(StringToEncode As String, Optional _
UsePlusRatherThanHexForSpace As Boolean = False) As String
Dim TempAns As String
Dim CurChr As Integer
CurChr = 1
Do Until CurChr - 1 = Len(StringToEncode)
Select Case Asc(Mid(StringToEncode, CurChr, 1))
Case 48 To 57, 65 To 90, 97 To 122
TempAns = TempAns & Mid(StringToEncode, CurChr, 1)
Case 32
If UsePlusRatherThanHexForSpace = True Then
TempAns = TempAns & "+"
Else
TempAns = TempAns & "%" & Hex(32)
End If
Case Else
TempAns = TempAns & "%" & _
Format(Hex(Asc(Mid(StringToEncode, _
CurChr, 1))), "00")
End Select
CurChr = CurChr + 1
Loop
URLEncode = TempAns
End Function
Public Function URLDecode(StringToDecode As String) As String
Dim TempAns As String
Dim CurChr As Integer
CurChr = 1
Do Until CurChr - 1 = Len(StringToDecode)
Select Case Mid(StringToDecode, CurChr, 1)
Case "+"
TempAns = TempAns & " "
Case "%"
TempAns = TempAns & Chr(Val("&h" & _
Mid(StringToDecode, CurChr + 1, 2)))
CurChr = CurChr + 2
Case Else
TempAns = TempAns & Mid(StringToDecode, CurChr, 1)
End Select
CurChr = CurChr + 1
Loop
URLDecode = TempAns
End Function