Loading ...
Sorry, an error occurred while loading the content.
 

Re: [PBML] You asked to see the code I am working on....

Expand Messages
  • Luinrandir Hernsen
    The piece of code I posted is to see if the ruin is owned or not. then it will asign the new owner to the ruin and take the coins from him. I have a var
    Message 1 of 16 , Sep 1, 2004
      The piece of code I posted is to see if the ruin is "owned" or not.
      then it will asign the new owner to the ruin and take the coins from him.
      I have a var $TownCurrent that tell sthe program what town you are in.
      you can only but the ruin of the town you are in, so when you buy the ruin
      the subroutine searches for an owner of $TownCurrent (the town you are currently in)
      and if it is not owned, you are offer the option to buy it, if you have the coins,
      if you don't have the coins the CastleRules() subrountine prints the info you need to know
      on what you need to buy the ruiins and turn it into your castle.

      There is a list is town, about 100 city names.

      What I think I need to do is figure out how to write and read a hash to a file.
      I started readin about hashes yesterday.


      now questions about what you wrote... which will take days to read up on and figure out what you just did :)


      Are the city name variables being used outside
      the sub? If not, this probably does the same thing.

      This file will be used by everyone in the game to see how owns what.
      so yes, teh file info will be used, the vars may or may not be...
      i'm not able to forsee how or when I would use the same vars...

      sub CastleTitleRecord {
      my $file = 'Title.db';


      ok... I just got this...
      if the file is not there, do this.. ok got it.

      unless ( -e $file ) {
      print
      q|The Title Clerk is missing!!!<BR>|,
      q|Report this immediately to |,
      q|Luinrandir@... and stop playing.<BR>|;
      exit;
      }

      I am guessing FH is the same as the FILENAME name i was using.
      I will have to research :$! but I am guessing that it a print command
      or a temp var?

      open FH, $file or die qq(Cannot open "$file": $!);

      is LOCK_EX the actual code or are they to be replaced with "2"?
      flock FH,2; #?????

      flock FH, LOCK_EX;

      my @cities;
      while ( <FH> ) {
      chomp;
      @cities = split ',';
      }

      close FH or die qq(Cannot close "$file": $!);

      ## Update new purchase, subtract coins etc

      $CastleVar = $cities[0];
      $CastleCity = 'Avalon';
      if ( $TownCurrent eq $CastleCity ) {
      if ( $CastleVar eq '' ) {
      print qq|No one owns the ruins of $CastleCity.<BR>|;

      if ( $Coins >= 20000 ) {
      print qq|Do you wish to buy it?|;
      } else {
      CastleRules();
      }

      } else {
      print
      qq|$CastleVar is the current owner |,
      qq|of Castle $CastleCity.<BR>|;
      }
      } else {
      print qq|error|;
      }

      open FH, ">$file" or die qq(Cannot open "$file": $!);
      flock FH, LOCK_EX;

      print FH join( ',', @cities ), "\n";

      close FH or die qq(Cannot close "$file": $!);
      }

      Right, I forgot to change Avalon to something like $CityList[1]
      $TownCurrent tells the subroutine what town you are in.

      What I don't understand is the middle part. It's
      only acting on one city. How does the code "know" that
      'Avolon' is the city to purchase. Is there another sub
      like this for each city?!?

      Nothing seems to happen if I have the cash. We
      print something, but we don't call a sub to handle the
      input.

      CastleRules() is a print qq|Here is what you need to do and have to buy a ruin.|;
      What's in CastleRules()?

      This is where the line/command goes that changes the players info (like $Money=$Money-20000)
      >>> ## Update new purchase, subtract coins etc

      $CastleVar = $cities[0];
      $CastleCity = 'Avalon';
      if ( $TownCurrent eq $CastleCity ) {
      if ( $CastleVar eq '' ) {
      print qq|No one owns the ruins of $CastleCity.<BR>|;

      if ( $Coins >= 20000 ) {
      print qq|Do you wish to buy it?|;
      } else {
      CastleRules();
      }

      } else {
      print
      qq|$CastleVar is the current owner |,
      qq|of Castle $CastleCity.<BR>|;
      }
      } else {
      print qq|error|;
      }


      And here is my bottom post, which i personally hate to do.. yes, I one of those -top posters-!
      I am going to rewrite this code and use a hash to read and write the file...
      soon as I figure out how....

      Lou







      [Non-text portions of this message have been removed]
    • Dave Gray
      ... #!/usr/bin/perl -w use strict; open F,
      Message 2 of 16 , Sep 1, 2004
        > while (<DFH>) {
        > # do stuff...
        > # indicate progress (BIG file = 1_253_684 lines...)
        > (($. % 100_000) == 0) and warn "Line $.\n";
        > }
        > ______________
        > STILL Yields:
        > Line 0
        > Line 200000
        > Line 300000
        > Line 500000
        > Line 600000
        > Line 900000
        > Line 1100000
        > Line 1200000

        #!/usr/bin/perl -w
        use strict;

        open F, '< lotsolines' or die "couldn't read: $!\n";
        while (<F>) {
        (($. % 100_000) == 0) and warn "at line $.\n";
        }
        close F;
        __OUTPUT__
        at line 100000
        at line 200000
        at line 300000
        at line 400000
        at line 500000
        at line 600000
        at line 700000
        at line 800000
        at line 900000
        at line 1000000
        (using perl 5.8.0 on RH9)

        > How can that be??

        Ehm. I'm not sure why it's getting a 0. What platform are you running
        on? Maybe it's skipping some of the other lines because your program
        happens to skip that exact line for some reason (ignoring comments or
        something). What's going on in "#do stuff"?
      • Allan Dystrup
        ... running ... or ... Here s the full Monthy for the block in question: ___________________________________________________________________ while ( ) { #
        Message 3 of 16 , Sep 1, 2004
          --- In perl-beginner@yahoogroups.com, Dave Gray <yargevad@g...> wrote:
          > > while (<DFH>) {
          > > # do stuff...
          > > # indicate progress (BIG file = 1_253_684 lines...)
          > > (($. % 100_000) == 0) and warn "Line $.\n";
          > > }
          > > ______________
          > > STILL Yields:
          > > Line 0
          > > Line 200000
          > > Line 300000
          > > Line 500000
          > > Line 600000
          > > Line 900000
          > > Line 1100000
          > > Line 1200000
          >
          > #!/usr/bin/perl -w
          > use strict;
          >
          > open F, '< lotsolines' or die "couldn't read: $!\n";
          > while (<F>) {
          > (($. % 100_000) == 0) and warn "at line $.\n";
          > }
          > close F;
          > __OUTPUT__
          > at line 100000
          > at line 200000
          > at line 300000
          > at line 400000
          > at line 500000
          > at line 600000
          > at line 700000
          > at line 800000
          > at line 900000
          > at line 1000000
          > (using perl 5.8.0 on RH9)
          >
          > > How can that be??
          >
          > Ehm. I'm not sure why it's getting a 0. What platform are you
          running
          > on? Maybe it's skipping some of the other lines because your program
          > happens to skip that exact line for some reason (ignoring comments
          or
          > something). What's going on in "#do stuff"?


          Here's the full Monthy for the block in question:
          ___________________________________________________________________
          while (<DFH>) {
          # the do stuff
          next if (! m/^\d{2}-\d-\d{4}/ ); # skip a couple of header lines
          s/\s//g; # squash whitespace
          my ($T,$M, $SVC, $TNS, $UID, $S,$R,$A,$C, $Y) = split /,/;
          ($DBG & 0x8) and print "[$T][$M][$SVC][$TNS][$UID][$S][$R][$A][$C]
          [$Y]\n";
          $K = uc(substr($SVC,0,2)); # setup hash key
          $hSVC{ lookup_app($K) }++;
          ($DBG & 0x8) and printf "\t%s=>%s\n", $K, lookup_app($K);

          !($. % 100_000) and warn "Line $.\n";
          }
          ___________________________________________________________________

          The "do stuff" seems to be doing doing all right

          ActivePerl Build 809
          Summary of my perl5 (revision 5 version 8 subversion 3) configuration:
          Platform:
          osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread

          thanks,
          allan (pardon my french) dystrup
        • Allan Dystrup
          Revised code _________________________________________________ while ( ) { !($. % 100_000) and warn Line $. n ; next if (! m/^ d{2}- d- d{4}/ ); # etc...
          Message 4 of 16 , Sep 1, 2004
            Revised code
            _________________________________________________
            while (<DFH>) {
            !($. % 100_000) and warn "Line $.\n";
            next if (! m/^\d{2}-\d-\d{4}/ );
            # etc...
            }
            _________________________________________________
            Yields (as expected):
            Line 100000
            Line 200000
            Line 300000
            Line 400000
            Line 500000
            Line 600000
            Line 700000
            Line 800000
            Line 900000
            Line 1000000
            Line 1100000
            Line 1200000
            ________________________________________________
            What can i say, but *blush*
            TNX Dave, you got me thinking here.

            I expected a well structured input file
            but it seems i have to check the lines around
            100.000, 400.000 and more
            sigh

            allan
          • Dave Gray
            ... That next line looks suspicious to me... how about: print( skipping $. n ), next if (! m/^ d{2}- d- d{4}/ ); to see how many lines it skips? Or even:
            Message 5 of 16 , Sep 1, 2004
              > ___________________________________________________________________
              > while (<DFH>) {
              > # the do stuff
              > next if (! m/^\d{2}-\d-\d{4}/ ); # skip a couple of header lines
              > s/\s//g; # squash whitespace
              > my ($T,$M, $SVC, $TNS, $UID, $S,$R,$A,$C, $Y) = split /,/;
              > ($DBG & 0x8) and print "[$T][$M][$SVC][$TNS][$UID][$S][$R][$A][$C]
              > [$Y]\n";
              > $K = uc(substr($SVC,0,2)); # setup hash key
              > $hSVC{ lookup_app($K) }++;
              > ($DBG & 0x8) and printf "\t%s=>%s\n", $K, lookup_app($K);
              >
              > !($. % 100_000) and warn "Line $.\n";
              > }
              > ___________________________________________________________________

              That 'next' line looks suspicious to me... how about:

              print("skipping $.\n"), next if (! m/^\d{2}-\d-\d{4}/ );

              to see how many lines it skips? Or even:

              print "line $.: $_\n" if $. == 100_000;

              before and after the 'next' line to debug a specific missing one.

              > thanks,
              > allan (pardon my french) dystrup

              :) which part is the french?
            • Allan Dystrup
              ... lines ... [$C] ... ================================================================== Yup, you re quite right here Dave... that next line was the villain.
              Message 6 of 16 , Sep 1, 2004
                --- In perl-beginner@yahoogroups.com, Dave Gray <yargevad@g...> wrote:
                > >
                ___________________________________________________________________
                > > while (<DFH>) {
                > > # the do stuff
                > > next if (! m/^\d{2}-\d-\d{4}/ ); # skip a couple of header
                lines
                > > s/\s//g; # squash whitespace
                > > my ($T,$M, $SVC, $TNS, $UID, $S,$R,$A,$C, $Y) = split /,/;
                > > ($DBG & 0x8) and print "[$T][$M][$SVC][$TNS][$UID][$S][$R][$A]
                [$C]
                > > [$Y]\n";
                > > $K = uc(substr($SVC,0,2)); # setup hash key
                > > $hSVC{ lookup_app($K) }++;
                > > ($DBG & 0x8) and printf "\t%s=>%s\n", $K, lookup_app($K);
                > >
                > > !($. % 100_000) and warn "Line $.\n";
                > > }
                > >
                ___________________________________________________________________
                >
                > That 'next' line looks suspicious to me... how about:
                >
                > print("skipping $.\n"), next if (! m/^\d{2}-\d-\d{4}/ );
                >
                > to see how many lines it skips? Or even:
                >
                > print "line $.: $_\n" if $. == 100_000;
                >
                > before and after the 'next' line to debug a specific missing one.
                >
                > > thanks,
                > > allan (pardon my french) dystrup
                >
                > :) which part is the french?

                ==================================================================

                Yup, you're quite right here Dave...
                that next line was the villain.

                Here's how the code ended up:
                __________________________________________________________________
                while (<DFH>) {
                !($. % 100_000) and warn "Line $.\n";
                if (! m/^\d{1,2}-\d{1,2}-\d{4}/ ) { # Skip header lines
                warn "Discarding line: $.\n"; next;
                };
                s/\s//g; # Squash whitespace
                my ($T,$M, $SVC, $TNS, $UID, $S,$R,$A,$C, $Y) = split /,/;
                ($DBG & 0x8) and print "[$T][$M][$SVC][$TNS][$UID][$S][$R][$A][$C]
                [$Y]\n";
                $K = uc(substr($SVC,0,2));
                $hSVC{ lookup_app($K) }++;
                ($DBG & 0x8) and printf "\t%s=>%s\n", $K, lookup_app($K);
                }
                ________________________________________________________________

                The former version had m/^\d{2}-\d-\d{4}/
                assuming a format of dd-d-dddd for day-month-year
                for the leading timestamp of data records for month April --
                which matched the first 100 lines or so (which i inspected)
                but.... not records like d-d-dddd as showed up around
                the "missing" lines in the progress trace...

                MORALE: yes, as you suggest Dave - be sure to trace any
                input data that you "discard" on the assumption, that
                it will only occur under certain known circumstances --
                Trere's always those other circumstances, that you have
                NOT anticipated.

                Thanks again,
                allan (the "french" is my variable naming convention here,
                which is mostly for internal use...) dystrup
              • Charles K. Clarkson
                ... So it is incomplete? That explains a lot. I had assumed you were sending working code from the game. ... Is this a new feature of the game? If it is, is
                Message 7 of 16 , Sep 1, 2004
                  From: Luinrandir Hernsen <mailto:Luinrandir@...> wrote:

                  : The piece of code I posted is to see if the ruin is "owned"
                  : or not. then it will asign the new owner to the ruin and
                  : take the coins from him.

                  So it is incomplete? That explains a lot. I had assumed
                  you were sending working code from the game.


                  : I have a var $TownCurrent that tells the program what town
                  : you are in. you can only but the ruin of the town you are
                  : in, so when you buy the ruin the subroutine searches for
                  : an owner of $TownCurrent (the town you are currently in)
                  : and if it is not owned, you are offer the option to buy it,
                  : if you have the coins, if you don't have the coins the
                  : CastleRules() subrountine prints the info you need to know
                  : on what you need to buy the ruiins and turn it into your
                  : castle.

                  Is this a new feature of the game? If it is, is the
                  file currently used by any other routine?


                  : There is a list is town, about 100 city names.
                  :
                  : What I think I need to do is figure out how to write and
                  : read a hash to a file. I started readin about hashes
                  : yesterday.

                  There are several modules for writing hashes to files,
                  but a hash may not be your best solution. At least, not
                  the way I think you are thinking of them.

                  The logic of your code seems to indicate that the
                  script work with a fixed number of preset cities
                  (castles). A better design would allow the code to work
                  with any castle names. Form a few to a few thousand
                  without changing the code.


                  : now questions about what you wrote... which will
                  : take days to read up on and figure out what you
                  : just did :)

                  Hope I can contribute a few sleepless nights. :)


                  : : Are the city name variables being used outside
                  : : the sub?
                  :
                  : This file will be used by everyone in the game to
                  : see who owns what. so yes, teh file info will be
                  : used, the vars may or may not be...
                  : i'm not able to forsee how or when I would use the
                  : same vars...


                  Sorry. This question was written assuming this
                  sub was part of working code. I'll assume an answer
                  of "No, but the sub may need to return some things
                  to the caller."


                  : sub CastleTitleRecord {
                  : my $file = 'Title.db';
                  :
                  :
                  : ok... I just got this...
                  : if the file is not there, do this.. ok got it.
                  :
                  : unless ( -e $file ) {
                  : print
                  : q|The Title Clerk is missing!!!<BR>|,
                  : q|Report this immediately to |,
                  : q|Luinrandir@... and stop playing.<BR>|;
                  : exit; }
                  :
                  : I am guessing FH is the same as the FILENAME name i was using.

                  Sorry, I have a macro in my editor for opening files.
                  I rarely use anything other than FH.


                  : I will have to research :$! but I am guessing that it a print
                  : command or a temp var?
                  :
                  : open FH, $file or die qq(Cannot open "$file": $!);

                  Read 'perlvar' from the documentation. $! holds the
                  text for errors from perl. It gives the error, the line
                  number and such. It's very handy for debugging code.


                  :
                  : is LOCKE the actual code or are they to be replaced with "2"?
                  : flock FH,2; #?????
                  :
                  : flock FH, LOCK_EX;

                  Yes, I think Jenda or Japhy recommended it in this
                  thread. The flock constants are imported from the
                  Fcntl.pm module. It assumes "use Fcntl qw( :flock );"
                  is located somewhere in the script.



                  [snip]
                  :
                  : $CastleVar = $cities[0];
                  : $CastleCity = 'Avalon';
                  : if ( $TownCurrent eq $CastleCity ) {
                  : if ( $CastleVar eq '' ) {
                  : print qq|No one owns the ruins of $CastleCity.<BR>|;
                  :
                  : if ( $Coins >= 20000 ) {
                  : print qq|Do you wish to buy it?|;
                  : } else {
                  : CastleRules();
                  : }
                  :
                  : } else {
                  : print
                  : qq|$CastleVar is the current owner |,
                  : qq|of Castle $CastleCity.<BR>|;
                  : }
                  : } else {
                  : print qq|error|;
                  : }
                  [snip]
                  :
                  : Right, I forgot to change Avalon to something like
                  : $CityList[1] $TownCurrent tells the subroutine what
                  : town you are in.

                  Ah! So this is the part you originally started the
                  thread for. I see now. Should have realized that earlier.


                  : What I don't understand is the middle part. It's
                  : only acting on one city. How does the code "know" that
                  : 'Avolon' is the city to purchase. Is there another sub
                  : like this for each city?!?
                  :
                  : Nothing seems to happen if I have the cash. We
                  : print something, but we don't call a sub to handle the
                  : input.
                  :
                  : CastleRules() is a print qq|Here is what you need to
                  : do and have to buy a ruin.|;
                  : What's in CastleRules()?
                  :
                  : This is where the line/command goes that changes the
                  : players info (like $Money=$Money-20000)
                  :
                  : ## Update new purchase, subtract coins etc
                  :
                  [snipped code]:
                  :
                  : And here is my bottom post, which i personally hate
                  : to do.. yes, I one of those -top posters-!

                  Yes, I know one of your more annoying habits. :)


                  : I am going to rewrite this code and use a hash to
                  : read and write the file...
                  : soon as I figure out how....

                  Are you using the castle names in any part of the
                  existing code? How are they used? Can you show me the
                  code?


                  HTH,

                  Charles K. Clarkson
                  --
                  Mobile Homes Specialist
                  254 968-8328
                • Luinrandir Hernsen
                  all 8000 lines? this is just the part i am working on now... what I need to do is figure out how to read and write hashes. Lou ... From: Charles K. Clarkson
                  Message 8 of 16 , Sep 1, 2004
                    all 8000 lines?
                    this is just the part i am working on now...
                    what I need to do is figure out how to read and write hashes.
                    Lou
                    ----- Original Message -----
                    From: Charles K. Clarkson
                    To: perl-beginner@yahoogroups.com
                    Sent: Wednesday, September 01, 2004 2:25 PM
                    Subject: RE: [PBML] You asked to see the code I am working on....


                    From: Luinrandir Hernsen <mailto:Luinrandir@...> wrote:

                    : The piece of code I posted is to see if the ruin is "owned"
                    : or not. then it will asign the new owner to the ruin and
                    : take the coins from him.

                    So it is incomplete? That explains a lot. I had assumed
                    you were sending working code from the game.


                    : I have a var $TownCurrent that tells the program what town
                    : you are in. you can only but the ruin of the town you are
                    : in, so when you buy the ruin the subroutine searches for
                    : an owner of $TownCurrent (the town you are currently in)
                    : and if it is not owned, you are offer the option to buy it,
                    : if you have the coins, if you don't have the coins the
                    : CastleRules() subrountine prints the info you need to know
                    : on what you need to buy the ruiins and turn it into your
                    : castle.

                    Is this a new feature of the game? If it is, is the
                    file currently used by any other routine?


                    : There is a list is town, about 100 city names.
                    :
                    : What I think I need to do is figure out how to write and
                    : read a hash to a file. I started readin about hashes
                    : yesterday.

                    There are several modules for writing hashes to files,
                    but a hash may not be your best solution. At least, not
                    the way I think you are thinking of them.

                    The logic of your code seems to indicate that the
                    script work with a fixed number of preset cities
                    (castles). A better design would allow the code to work
                    with any castle names. Form a few to a few thousand
                    without changing the code.


                    : now questions about what you wrote... which will
                    : take days to read up on and figure out what you
                    : just did :)

                    Hope I can contribute a few sleepless nights. :)


                    : : Are the city name variables being used outside
                    : : the sub?
                    :
                    : This file will be used by everyone in the game to
                    : see who owns what. so yes, teh file info will be
                    : used, the vars may or may not be...
                    : i'm not able to forsee how or when I would use the
                    : same vars...


                    Sorry. This question was written assuming this
                    sub was part of working code. I'll assume an answer
                    of "No, but the sub may need to return some things
                    to the caller."


                    : sub CastleTitleRecord {
                    : my $file = 'Title.db';
                    :
                    :
                    : ok... I just got this...
                    : if the file is not there, do this.. ok got it.
                    :
                    : unless ( -e $file ) {
                    : print
                    : q|The Title Clerk is missing!!!<BR>|,
                    : q|Report this immediately to |,
                    : q|Luinrandir@... and stop playing.<BR>|;
                    : exit; }
                    :
                    : I am guessing FH is the same as the FILENAME name i was using.

                    Sorry, I have a macro in my editor for opening files.
                    I rarely use anything other than FH.


                    : I will have to research :$! but I am guessing that it a print
                    : command or a temp var?
                    :
                    : open FH, $file or die qq(Cannot open "$file": $!);

                    Read 'perlvar' from the documentation. $! holds the
                    text for errors from perl. It gives the error, the line
                    number and such. It's very handy for debugging code.


                    :
                    : is LOCKE the actual code or are they to be replaced with "2"?
                    : flock FH,2; #?????
                    :
                    : flock FH, LOCK_EX;

                    Yes, I think Jenda or Japhy recommended it in this
                    thread. The flock constants are imported from the
                    Fcntl.pm module. It assumes "use Fcntl qw( :flock );"
                    is located somewhere in the script.



                    [snip]
                    :
                    : $CastleVar = $cities[0];
                    : $CastleCity = 'Avalon';
                    : if ( $TownCurrent eq $CastleCity ) {
                    : if ( $CastleVar eq '' ) {
                    : print qq|No one owns the ruins of $CastleCity.<BR>|;
                    :
                    : if ( $Coins >= 20000 ) {
                    : print qq|Do you wish to buy it?|;
                    : } else {
                    : CastleRules();
                    : }
                    :
                    : } else {
                    : print
                    : qq|$CastleVar is the current owner |,
                    : qq|of Castle $CastleCity.<BR>|;
                    : }
                    : } else {
                    : print qq|error|;
                    : }
                    [snip]
                    :
                    : Right, I forgot to change Avalon to something like
                    : $CityList[1] $TownCurrent tells the subroutine what
                    : town you are in.

                    Ah! So this is the part you originally started the
                    thread for. I see now. Should have realized that earlier.


                    : What I don't understand is the middle part. It's
                    : only acting on one city. How does the code "know" that
                    : 'Avolon' is the city to purchase. Is there another sub
                    : like this for each city?!?
                    :
                    : Nothing seems to happen if I have the cash. We
                    : print something, but we don't call a sub to handle the
                    : input.
                    :
                    : CastleRules() is a print qq|Here is what you need to
                    : do and have to buy a ruin.|;
                    : What's in CastleRules()?
                    :
                    : This is where the line/command goes that changes the
                    : players info (like $Money=$Money-20000)
                    :
                    : ## Update new purchase, subtract coins etc
                    :
                    [snipped code]:
                    :
                    : And here is my bottom post, which i personally hate
                    : to do.. yes, I one of those -top posters-!

                    Yes, I know one of your more annoying habits. :)


                    : I am going to rewrite this code and use a hash to
                    : read and write the file...
                    : soon as I figure out how....

                    Are you using the castle names in any part of the
                    existing code? How are they used? Can you show me the
                    code?




                    well here i am bottom posting... and as usual i can't get rid of the damn
                    line in the side.....
                    the castle names are also the city names. Each city will have a .db file
                    ie Avalon.db......

                    so my choice now is, write to the file using arrays of hashes....
                    since i know how to read/write arrays.. guess that is how i will do it.
                    Lou



                    [Non-text portions of this message have been removed]
                  • Charles K. Clarkson
                    Luinrandir Hernsen wrote: Top and bottom posting. You re killing me here ... [best spoken with a Brooklyn accent.] ... You should
                    Message 9 of 16 , Sep 1, 2004
                      Luinrandir Hernsen <Luinrandir@...> wrote:

                      Top and bottom posting. You're killing me here ...
                      [best spoken with a Brooklyn accent.]


                      : : Are you using the castle names in any part
                      : : of the existing code? How are they used? Can you
                      : : show me the c ode?

                      : all 8000 lines?

                      You should probably send it to me off-list, but, yes,
                      I'd like to look at it. I do not guarantee I won't run
                      away screaming.


                      : this is just the part i am working on now...
                      : what I need to do is figure out how to read
                      : and write hashes.

                      A hash is like an array except the indexes are named
                      and not kept in any particular order. Just as you can
                      list the indexes to an array:

                      foreach my $index ( 0 .. $#array ) {

                      and its values:

                      foreach my $element ( @array ) {


                      You can do the same for a hash:

                      foreach my $key ( keys %hash ) {

                      and its values

                      foreach my $value ( values %hash ) {

                      : well here i am bottom posting... and as usual i can't get
                      : rid of the damn line in the side.....

                      What line in the side? Oh, wait, default your replies
                      to plain text. Then you can intersperse your comments in
                      the response.


                      : the castle names are also the city names. Each city will
                      : have a .db file
                      : ie Avalon.db......

                      I figured you'd use something like that. I foresee a problem
                      when you want to add a new city. What you have shown so far looks
                      like the cities are hard coded into the code. It would be more
                      robust if any amount of cities could be added or deleted anytime.


                      : so my choice now is, write to the file using arrays of
                      : hashes.... since i know how to read/write arrays.. guess that
                      : is how i will do it.

                      You sound like the guy at the hardware store who is looking
                      at the power drills knowing that is what he needs to drill his
                      fastener into the slab. Unfortunately he is totally unaware of
                      the Hilti Gun on the next aisle.

                      A hash will probably do what you need, but an introduction
                      to data structures might be more worthwhile reading.

                      BTW, does the game already have castles and cities? I took
                      a look at the map, but I couldn't tell. I think it may only
                      work in IE.


                      HTH,

                      Charles K. Clarkson
                      --
                      Mobile Homes Specialist
                      254 968-8328
                    Your message has been successfully submitted and would be delivered to recipients shortly.