473,698 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Odd function problem

I have a function as follows:

function docolors(Rstart ,Gstart,Bstart, color,increment er)
r=Rstart
g=Gstart
b=Bstart
response.write "<div><table><t r>"
for color = 0 to 255
response.write "<td style=""backgro und-color:rgb"
response.write "(" & r & "," & g & "," & b & ");"">"
response.write "<a href=""#"" title=""R"
response.write r & ":G" & g & ":B" & b & """>"
response.write "&nbsp;&nbsp;&n bsp;</a></td>"
color=color+inc rementer
next
response.write "</tr></table></div>"
end function

When its called thus:

docolors 0,0,0,r,9

it increments the value of red by 9 and writes 26 table cells to the
page gradually going from black to red (which is what I want).

I have a form to collect user provided values for the function's
arguments and dynamically build a call to docolors() using the form
field values:
<%
sub dropdown()
for i = 0 to 255
response.write "<option value=""" & i & """>" & i & "</option>" &
vbcrlf
next
end sub
%>
<form action="" method="post">
<strong>Start Values</strong><br />
Red:<select name="r">
<%
dropdown
%>
</select>
Green:<select name="g">
<%
dropdown
%>
</select>
Blue:<select name="b">
<%
dropdown
%>
</select><br /><br />
<strong>Colou r to increment value of:</strong><br />
<input type="radio" name="c" value="r" />Red<br />
<input type="radio" name="c" value="g" />Green<br />
<input type="radio" name="c" value="b" />Blue<br /><br />
<strong>Increme nter:</strong><br />
<select name="i">
<%
dropdown
%>
</select><br />
<input type="submit" name="submit" value="Submit" />
</form>

<%
x=cint(request. form("r"))
y=cint(request. form("g"))
z=cint(request. form("b"))
h=trim(cstr(req uest.form("c")) )
i=cint(request. form("i"))

docolors x,y,z,h,i
%>

and it seems that all the values translate correctly if I
response.write the whole lot:

response.write "call docolors(" & x & "," & y & "," & z & "," & h & ","
& i & ")<br />"

but the thing fails to increment the value of h - the paramenter that
goes where color is in the function. x,y,z,and i all work as expected.

My logic is clearly faulty somewhere. Can anyone see where?

TIA

Mike

Jan 15 '06 #1
2 1452
Mike wrote:
function docolors(Rstart ,Gstart,Bstart, color,increment er)
r=Rstart
g=Gstart
b=Bstart
response.write "<div><table><t r>"
for color = 0 to 255
response.write "<td style=""backgro und-color:rgb"
response.write "(" & r & "," & g & "," & b & ");"">"
response.write "<a href=""#"" title=""R"
response.write r & ":G" & g & ":B" & b & """>"
response.write "&nbsp;&nbsp;&n bsp;</a></td>"
color=color+inc rementer
next
response.write "</tr></table></div>"
end function
....
but the thing fails to increment the value of h - the
paramenter that goes where color is in the function.
x,y,z,and i all work as expected.

You are ignoring the parameter [color] and initializing it to 0 in your
loop.
--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
Jan 16 '06 #2

Dave Anderson wrote:
Mike wrote:
function docolors(Rstart ,Gstart,Bstart, color,increment er)
r=Rstart
g=Gstart
b=Bstart
response.write "<div><table><t r>"
for color = 0 to 255
response.write "<td style=""backgro und-color:rgb"
response.write "(" & r & "," & g & "," & b & ");"">"
response.write "<a href=""#"" title=""R"
response.write r & ":G" & g & ":B" & b & """>"
response.write "&nbsp;&nbsp;&n bsp;</a></td>"
color=color+inc rementer
next
response.write "</tr></table></div>"
end function


...
but the thing fails to increment the value of h - the
paramenter that goes where color is in the function.
x,y,z,and i all work as expected.

You are ignoring the parameter [color] and initializing it to 0 in your
loop.
--
Dave Anderson


Thank, Dave. I've rewritten it and it works as expected now:

function docolors(Rstart ,Gstart,Bstart, color,increment er)
dim r,g,b,i
r=Rstart
g=Gstart
b=Bstart
response.write "<div><table><t r>"
select case color
case "r"
for i = r to 255
response.write "<td style=""backgro und-color:rgb"
response.write "(" & i & "," & g & "," & b & ");"">"
response.write "<a href=""#"" title=""R"
response.write i & ":G" & g & ":B" & b & """>"
response.write "&nbsp;&nbsp;&n bsp;</a></td>"
i=i+incrementer
next
case "g"
for i = g to 255
response.write "<td style=""backgro und-color:rgb"
response.write "(" & r & "," & i & "," & b & ");"">"
response.write "<a href=""#"" title=""R"
response.write r & ":G" & i & ":B" & b & """>"
response.write "&nbsp;&nbsp;&n bsp;</a></td>"
i=i+incrementer
next
case "b"
for i = b to 255
response.write "<td style=""backgro und-color:rgb"
response.write "(" & r & "," & g & "," & i & ");"">"
response.write "<a href=""#"" title=""R"
response.write r & ":G" & g & ":B" & i & """>"
response.write "&nbsp;&nbsp;&n bsp;</a></td>"
i=i+incrementer
next
end select
response.write "</tr></table></div>"
end function

Mike

Jan 17 '06 #3

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

Similar topics

11
3753
by: Kostatus | last post by:
I have a virtual function in a base class, which is then overwritten by a function of the same name in a publically derived class. When I call the function using a pointer to the derived class (ClassB* b; b->func(); ) the base-class function is called instead of the new function in the derived class. All other similar functions (virtual in the base class and overwritten in the the derived class) work fine, it's just this one function. ...
4
3103
by: andy | last post by:
i am coding a dll which contains a function take a const wchar_t* as parameter, call it form a exe, the wchar_t is passed to dll function, but the function in dll will then call another function and pass that wchar_t* parameter to another function, now the problem is that functions in dll, when exported function pass parameter another one(unexported), they both residen in the same dll, between wchar_t* passing, the target function can't...
3
425
by: Jan-Henrik Grobe | last post by:
Hallo, I am coming to this newsgroup with a very strange Problem. I have two c++ files A.cpp and B.cpp....In A.cpp I am creating an openGL window and in B.cpp I have stored the callback functions. Important is, that the object A.o has to be created BEFORE B can be compiled. I am sure that sounds confusing but A.cpp is part of a library that is needed for objects I use in B (kind of client-server thing). So I cannot include a B.h in the...
2
2327
by: Hennie de Nooijer | last post by:
Because of an error in google or underlying site i can reply on my own issue. Therefore i copied the former entered message in this message. -------------------------------------REPY---------------------------------- Hi Maybe i wasn't clear. I want to dynamically check whether what the lowest date and the highest date is in the calendar table. The presented solutions has fixed dates and i don't want that. If i could store a global...
18
5920
by: jimfortune | last post by:
I have an A97 module called modWorkdayFunctions in: http://www.oakland.edu/~fortune/WorkdayFunctions.zip It allows the counting of workdays taking into consideration up to 11 U.S. holidays. More holidays can be added easily. Also, there is a boolean flag for including or excluding Saturdays or Sundays as part of the work week. The only thing I know of that is missing is that some holidays are observed on a Friday or a Monday if they...
4
6024
by: Andy_Khosravi | last post by:
Hello, I'm having a problem with the MID function within Access 97. I have been trying to build a function to check to make sure that a field on a form does not have any spaces or dashes. This should be easy enough to do using the MID function in a For...Next statement. However, I've had more than a few problems. My first problem was that I had a data type mismatch. Access simply refused to evaluate anything I put in there no matter...
7
5182
by: Mike D. | last post by:
I have a problem with a dynamic library I am developing, but it is really more of a pointer issue than anything else. Hopefully someone here can lend me some assistance or insight into resolving this. Ok... here goes.... I have a function that passes a pointer to a string to another function. For example: int FunctionA ()
2
2526
by: Fernando Barsoba | last post by:
Dear all, I have been posting about a problem trying to encrypt certain data using HMAC-SHA1 functions. I posted that my problem was solved, but unfortunately, I was being overly optimistic. I am really desperate now, because I havent' been able to locate the origin of the problem for a couple of days now.. PROBLEM: the message digest obtained differs each time I execute the code, but works perfectly when applying the "control", that...
78
4943
by: Josiah Manson | last post by:
I found that I was repeating the same couple of lines over and over in a function and decided to split those lines into a nested function after copying one too many minor changes all over. The only problem is that my little helper function doesn't work! It claims that a variable doesn't exist. If I move the variable declaration, it finds the variable, but can't change it. Declaring the variable global in the nested function doesn't work...
6
5917
by: RandomElle | last post by:
Hi there I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with or without parms. I know that any function that is passed to Eval() must be declared Public. It can be a Sub or Function, as long as it's Public. I even have it where the "function" evaluated by Eval can be in a form (class) module or in a standard...
0
8668
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
8598
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
9014
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8885
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
7708
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6515
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
4358
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
3037
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
2320
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.