FAQ Search Memberlist Usergroups
Jolt Country Forum Index
Register Profile Log in to check your private messages Log in
Log in Log in

Comparing Strings

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors
View previous topic :: View next topic  
Author Message
zoot



Joined: 29 Jul 2004
Posts: 6
Location: On the Level

PostPosted: Thu Jul 29, 2004 3:24 am    Post subject: Comparing Strings Reply with quote

Hi all,

I am having trouble getting my head around the way that Hugo handles arrays and strings. I want the user to enter a keycode, and then compare it to a pre-set string. Say my unlock code is "12345", what is the best way of dealing with this? I would expect my user to enter:

type "12345"

and then compare it to my reference. I have set up a custom routine for 'type', but no matter how I configure it, I can't get it to work.

The general code is as follows:

Code:
   if location = lockerroom
   {
      if <entered code = stored code> !pseudo code!!!!

      {
         "You have unlocked the door!"
      }
      else
      {
         "The keypad bleeps derisively as it rejects your code!"
      }
   }
   else
   {
      "There is nothing to type on in here."
   }


Any help, gratefully received.
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Thu Jul 29, 2004 5:29 am    Post subject: Reply with quote

Ok, I did it after reading the new "Book" - much better explanation, Kent, nice one :smile:

First, I defined a couple of arrays:

Code:
array keycode[6]='1','2','3','4','5',0
array keyentered[6]='1','2','3','4','5',0


And now here is the "type routine"

Code:
routine DoType
{
   string(keyentered,parse$,5)
   if location = lockerroom
   {
      
      if StringCompare(keyentered,keycode) = 0
      {
         "Well done, you have unlocked the door!"
      }
      else
      {
         "The keypad bleeps derisively as it rejects your code!"
      }
   }
   else
   {
      "There is nothing to type on in here."
   }
   return true
}


Getting there.... Maybe not the elegant way to do it, but it works :cool:
Back to top
Ice Cream Jonsey



Joined: 27 Apr 2002
Posts: 20088
Location: Colorado

PostPosted: Thu Jul 29, 2004 9:10 am    Post subject: Reply with quote

Excellent! Good to see that you got it working.

Also, welcome to the site! Questions usually get answered pretty quickly around here, I've found. If you get stuck on another Hugo bit let us know and we'll try it ourselves and see what's up.


Robb
_________________
the dark and gritty...Ice Cream Jonsey!
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Jolt Country Forum Index -> Hugo's House of Horrors All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001 phpBB Group

Theme by Kage Musha - RPG Garden

Copyrights and trademarks are all of the belonging company. No copyright Infringement intended