473,785 Members | 2,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem using Execute to dynamically create variables

Hi,

I am trying to re-write an old url management class I use, and am having
problems using the Execute method to create vars. I think i'm missing
something simple, as I have used this method several times to perform this
kind of action, maybe it just needs some fresh eyes :) The code i'm using is
as follows:
Class cURL
' *--- [ Private variable
declarations ] --------------------------------------------------*
Private i_ItemCount
Private i_URL, i_QSURL, arFieldNames

' *--- [ Initialisation/termination
routines ] ----------------------------------------------*
Private Sub Class_Initializ e()
arFieldNames = Array()
End Sub
Private Sub Class_Terminate ()
' Clean up objects and data
End Sub

' *--- [ Class
properties ] -------------------------------------------------------------*
Public Property Get cnt
cnt = i_ItemCount
End Property
Property Get URL
URL = i_URL
End Property
Property Get QSURL
QSURL = i_QSURL
End Property

' *--- [ Class
Methods ] ---------------------------------------------------------------*
Public Sub Load
Dim protocol, sQuery, i, x
Dim nStart, url, url_element, vItem
protocol = "" & Request.ServerV ariables("HTTPS ")
if LCase(protocol) = "on" Then protocol = "https://" else protocol =
"http://"
i_URL = protocol & Request.ServerV ariables("HTTP_ HOST") &
Request.ServerV ariables("SCRIP T_NAME")
' get QueryString if there is one
sQuery = Request.QuerySt ring()
if sQuery <> "" Then sQuery = "?" & sQuery Else sQuery = ""
i_QSURL = i_URL & sQuery
i_ItemCount = Request.QuerySt ring.Count
If i_ItemCount = 0 Then Exit Sub
' At this point we know we have some q string data
ReDim arFieldNames(i_ ItemCount)
' build the internal map of name-value pairs from the url.
url = Request.QuerySt ring()
url_element = split(url, "&")
'if the url has no parameters
if IsNull(url_elem ent(0)) Or url_element(0) = "" Then Exit Sub
'if the url has parameters
for i = 0 to UBound(url_elem ent)
vItem = split(url_eleme nt(i), "=")
arFieldNames(i) = vItem(0)
Execute("qs_" & arFieldNames(i) & "=" & vItem(1)) ' PROBLEM LINE
Next
End Sub

Public default Function Items(str_item)
Dim intOrdinal, i, strTest
If i_ItemCount = 0 Then Items = "" : Exit Function
strTest = "qs_" & str_item
If Len(Eval(strTes t)) = 0 Then
Items = "" ' Always returns this!
Else
Items = Eval(strTest)
End If
End Function
End Class

On the calling page:
<% Dim g_URL : Set g_URL = New cURL : g_URL.Load %>
<a href="<%= g_URL.URL & "?item1=astring &item2=lop"%>"> Test QueryString</a>
<br>
<br>
<br>
URL: <%= g_URL.URL %>
<br>
Full URL: <%= g_URL.QSURL %>
<br>
Item Count: <%= g_URL.cnt %>
<br>
Request item: <%= g_URL("item1") %>

Thanks for your time,
Colin
Jul 22 '05 #1
1 1502
Hi, sorry vbscript fatigue setting in! I found the problem, the line that
reads:
Execute("qs_" & arFieldNames(i) & "=" & vItem(1)) ' PROBLEM LINE

Should have read:
Execute("qs_" & arFieldNames(i) & " = """ & vItem(1) & """")
because the qs is a string.

Thanks anyway,
Colin
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2742
by: Max | last post by:
Hello. This is the first time I've posted to a newsgroup, and I do this because I'm in desperate need of help. I'm working a user management system, and when I activate a user that has registered to my system, the current admin user logged in gets logged out. I can't seem to work out how - I can't even trace back where some of the variables are coming from (for example, the "ref" part of the Request.QueryString method). Could someone...
0
1726
by: john | last post by:
Hi,All Gurus: It is kind of complicated, please bear with me and let me know if you have any questions. Thanks a lot in advance. John I have a csharp method, using emit to dynamically generate classes & method depends on the meta table in the database,here is my problem 1) One method I generated works when it was called, but another set of method does not work, it generate the following error
1
1713
by: Alex | last post by:
Hi, i have a problem with quoting in plpgsql. I try to insert dynamically some conditions into a select statment but for some reason it does not work. condition := '' AND price > 500 ''; SELECT INTO tmpRec * WHERE xxxxxx || condition || ORDER BY userId ; What is the correct way to do this ?
1
2580
by: Kamal Jeet Singh | last post by:
Hi Friends !! I am facing problem in controlling the dynamically created controls on web page. The problem Scenario is Scenario:- My requirement is to load the web user controls on the web page dynamically. To do this, First I including a web page (MainPage.aspx) and I made form tag to Runat=Server. I included one table tag and also made this table Runat=Server side. Second I created three Web User Controls e.g. wucCustomerInfo.ascx,
0
1641
by: Daniel Crespo | last post by:
Hi to all, I'm using adodb for accessing mysql and postgres. My problem relies on the mysql access. Sometimes, when I try to execute a query (using ExecTrans method below), I get this error: 'NoneType' object has no attribute 'cursor'
1
1537
by: mxliron | last post by:
hi all, this code is for a picture viewer. yes, this is my first code and my first piece of programming so i maybe simply be missing some key notions here. the problem is: the nav onclick event buttons to flip through the pics only work in IE and not in FF, i havnt tested anywhere else. I have tried lots of thing such as including the code directly after the event or in the headleft and headright functions, replacing the event function by...
10
2265
by: Paul | last post by:
Hi I am using the HtmlInputFile control to upload a file from a client to a server. I have a browse to find the file on the server but need to create the path dynamically as to were it will go based on some dropdown boxes, one for the year and one for the month. This line saves the file so I am trying to get the month and year from the dropdown boxes and put them in the month and year variables but this does not work,...
1
2284
by: johnjsforum | last post by:
Buddies, I have a web page to create HTML buttons dynamically as in the “formDivColorPicker” function //////////////////////////////////////////////////////////////////////////////////// version 1 : using global variables ////////////////////////////////////////////////////////////////// var _textField, _divColorPicker; // global vars window.onload = function() { _textField = document.getElementById('htxaMessage'); // fill...
0
4098
by: David | last post by:
- Are there any peculiarities with using curs.executemany(...) vs. multiple How many times are you calling execute vs a single executemany? The python call overhead will add up for thousands of calls. The relevant source code is here if you're interested: http://svn.python.org/projects/python/trunk/Modules/_sqlite/cursor.c
0
9645
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10330
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10093
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9952
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7500
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.