473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Odd function problem

I have a function as follows:

function docolors(Rstart,Gstart,Bstart,color,incrementer)
r=Rstart
g=Gstart
b=Bstart
response.write "<div><table><tr>"
for color = 0 to 255
response.write "<td style=""background-color:rgb"
response.write "(" & r & "," & g & "," & b & ");"">"
response.write "<a href=""#"" title=""R"
response.write r & ":G" & g & ":B" & b & """>"
response.write "&nbsp;&nbsp;&nbsp;</a></td>"
color=color+incrementer
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>Colour 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>Incrementer:</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(request.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 1442
Mike wrote:
function docolors(Rstart,Gstart,Bstart,color,incrementer)
r=Rstart
g=Gstart
b=Bstart
response.write "<div><table><tr>"
for color = 0 to 255
response.write "<td style=""background-color:rgb"
response.write "(" & r & "," & g & "," & b & ");"">"
response.write "<a href=""#"" title=""R"
response.write r & ":G" & g & ":B" & b & """>"
response.write "&nbsp;&nbsp;&nbsp;</a></td>"
color=color+incrementer
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,incrementer)
r=Rstart
g=Gstart
b=Bstart
response.write "<div><table><tr>"
for color = 0 to 255
response.write "<td style=""background-color:rgb"
response.write "(" & r & "," & g & "," & b & ");"">"
response.write "<a href=""#"" title=""R"
response.write r & ":G" & g & ":B" & b & """>"
response.write "&nbsp;&nbsp;&nbsp;</a></td>"
color=color+incrementer
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,incrementer)
dim r,g,b,i
r=Rstart
g=Gstart
b=Bstart
response.write "<div><table><tr>"
select case color
case "r"
for i = r to 255
response.write "<td style=""background-color:rgb"
response.write "(" & i & "," & g & "," & b & ");"">"
response.write "<a href=""#"" title=""R"
response.write i & ":G" & g & ":B" & b & """>"
response.write "&nbsp;&nbsp;&nbsp;</a></td>"
i=i+incrementer
next
case "g"
for i = g to 255
response.write "<td style=""background-color:rgb"
response.write "(" & r & "," & i & "," & b & ");"">"
response.write "<a href=""#"" title=""R"
response.write r & ":G" & i & ":B" & b & """>"
response.write "&nbsp;&nbsp;&nbsp;</a></td>"
i=i+incrementer
next
case "b"
for i = b to 255
response.write "<td style=""background-color:rgb"
response.write "(" & r & "," & g & "," & i & ");"">"
response.write "<a href=""#"" title=""R"
response.write r & ":G" & g & ":B" & i & """>"
response.write "&nbsp;&nbsp;&nbsp;</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
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...
4
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...
3
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...
2
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....
18
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. ...
4
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...
7
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...
2
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...
78
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...
6
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...

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.