• Navigation
Results 1 to 7 of 7
  1. #1
    a p. sweet dude
    Pens win! Pens Win!!! PENS WIN!!!!!

    Join Date
    Jul 2010
    Posts
    25,685
    BG Level
    10

    Any classic ASP people able to help me fix this?

    So I have this homework assignment. It's meant as a basic intro to server-side technologies (ASP, JSP, PHP). We pick a server-side technology and re-write a previous assignment to be a multi-page thing. First page just asks for your name and the upper bound for the game. Second page plays the game. Third page congratulates you on a win.

    So the assignment is just a basic game of High Low. I chose to do it in ASP. The page postback to itself is working (as far as I can tell), the issue I'm having is with one of my Ifs for the rules of the game.

    Pastebin page for the who .asp file. If it's easier I can also provide the other/first page that posts to this one: http://pastebin.com/c9Nx3YV6

    The current problem I have is that in this block

    Code:
                        if (lowGuess > guess) then
                            greeting = "That guess was way too low, " & username
                        elseif (guess > highGuess) then
                            greeting = "That guess was way too high, " & username
                        elseif (guess = rNum) then
                            'Redirect to the win page here
                        else
    the "if (guess > highGuess) then" condition seemingly always evaluates as true, and I have no clue why.

    Anyone able to see the mistake I'm making?

  2. #2
    Salvage Bans
    Join Date
    Feb 2007
    Posts
    811
    BG Level
    5
    FFXIV Character
    Orinthia Warsong
    FFXIV Server
    Excalibur
    FFXI Server
    Bahamut

    I'm not versed in asp, but the syntax looks similar to other things like vb (derp.net crap). Looking at the pastebin, "guess" and "highGuess" look like their both of type "var," meaning it might not be implicitly converting these to integer types for evaluation ("var" is a catchall type, kinda like Object type in java/c#). I don't know if asp does this on its own or not so check by doing the conversion to integer and then evaluating on the new values.

    Typed-in values are usually strings, and you don't normally do greater/less-than comparisons on strings.

  3. #3
    a p. sweet dude
    Pens win! Pens Win!!! PENS WIN!!!!!

    Join Date
    Jul 2010
    Posts
    25,685
    BG Level
    10

    Hm, I thought VBscript converted automatically, but I'll try that and see what happens, thanks.

  4. #4
    Salvage Bans
    Join Date
    Feb 2007
    Posts
    811
    BG Level
    5
    FFXIV Character
    Orinthia Warsong
    FFXIV Server
    Excalibur
    FFXI Server
    Bahamut

    Fuck, i looked over your pastebin too fast, it's not a var, it's a "dim" without a type associated. I wasn't looking far enough down the code, but same sort of deal.

    Looking at where your variables are being set and used, I noticed that maxBound might not be have a value and there's a spot where you set highGuess equal to maxBound. Request.QueryString("maxNum") might not be returning anything since there's no field anywhere in the page for it (unless it's in another part somewhere else, the rest or your Requests seem linked to things on inside the pastebin page; insert my asp ignorance here).


    add: and noticed this thing: if (lowGuess = "") then, this always strikes me wrong since most other languages use double-equals for this sort of evaluation but i don't remember if vb/asp said fuck you on this. Make sure those make sense lol.

  5. #5
    Salvage Bans
    Join Date
    Sep 2008
    Posts
    934
    BG Level
    5

    Quote Originally Posted by orinthia View Post
    if (lowGuess = "") then, this always strikes me wrong since most other languages use double-equals for this sort of evaluation but i don't remember if vb/asp said fuck you on this. Make sure those make sense lol.
    Yeah that needs to be ==

  6. #6
    a p. sweet dude
    Pens win! Pens Win!!! PENS WIN!!!!!

    Join Date
    Jul 2010
    Posts
    25,685
    BG Level
    10

    Quote Originally Posted by orinthia View Post
    I'm not versed in asp, but the syntax looks similar to other things like vb (derp.net crap). Looking at the pastebin, "guess" and "highGuess" look like their both of type "var," meaning it might not be implicitly converting these to integer types for evaluation ("var" is a catchall type, kinda like Object type in java/c#). I don't know if asp does this on its own or not so check by doing the conversion to integer and then evaluating on the new values.

    Typed-in values are usually strings, and you don't normally do greater/less-than comparisons on strings.
    I feel like such a dummy, this was totally the problem. CINT to the rescue.

    And yeah, VBscript is stupid and for comparisons it only uses =, not ==. I triple checked that first because it seemed so bizarre to me.

    Thanks for the help guys. I was losing my mind last night haha.

  7. #7
    Salvage Bans
    Join Date
    Feb 2007
    Posts
    811
    BG Level
    5
    FFXIV Character
    Orinthia Warsong
    FFXIV Server
    Excalibur
    FFXI Server
    Bahamut

    Eh it's easy to mess up when the language lets you do some things out of convenience (quirks kick your ass and are hard to find sometimes). You might be able to convert the variable in place to the type you're expecting so errors can happen in a more controlled manner.

    Expect to curse at your code for a while (fucking dot net). Write comments everywhere, especially on how you fixed something heh.

Similar Threads

  1. Guys can you help me with this?
    By wolffsrain in forum Tech
    Replies: 23
    Last Post: 2008-10-26, 15:28
  2. Help me diagnose this
    By Intense in forum Tech
    Replies: 2
    Last Post: 2008-06-26, 22:42