Páginas: [1]
Tags: PERL FUNTION MSGSIZE PAGENATE PAGESIZE QUOT STRT SUBSTR UMM VIEWC
  Autor: Tema: Pagenated Articles?
offline Woo Hoo
Última Visita: 09/28/14

Administrator
Dev
Joined: 05/26/06
Notas en Foros: 2289
 Pagenated Articles?
 Enviado el: 11/05/10 en 03:14:37

Here's some code to help give you an idea of simple it is to pagenate the articles.
There's other code to access them but this is just to give you a taste and see if
there's any real interest in this.

This is placed after we got the message ie $message = $item[5];


código:

# total characters in message
my $msgsize = length($message);

# keep track of loop iterations
my $c = 0;

# the substr funtion offset
my $offset = 0;

# the substr function length
# this can be changed to suite your needs
my $pagesize = 1500;

# each page saved in the array
my $page = "";

# the page array
my @pages;

# iterate until the count times the page size is
# equal to or greater than the message size
while (($c*$pagesize) < $msgsize) {
   
   # create a page using Perl's substr function
   $page = substr($message, $offset, $pagesize);
   
   # only trim the page if it's full size!
   # why? because the page may end up being shorter
   # than $pagesize and we might loose some characters
   # on the last page if we don't do this
   if ((length($page)) == $pagesize) {
      $page =~ s/(.*)\s.*/$1/;
   }
   
   # add each page to the array
   push(@pages, $page);
   
   # umm... maybe I can get rid of this now
   $strt = ($c*$pagesize);
   
   # increment the loop count
   $c++;
   
   # umm... I think this can go too
   $viewc = $c;
   
   # reset the offset to the end of the last page
   $offset += length($page);
   
} # end loop

# the message is accessed via @pages now
$message = $pages[$start];





0 but true
Conectado
       
offline Flex
Última Visita: 11/27/10

Level 1
Joined: 09/16/10
Notas en Foros: 17
 Re: Paginated Articles?
 Enviado el: 11/05/10 en 11:46:17


Woo Hoo said Today, 8 hours and 25 minutes ago.:
Here's some code to help give you an idea of simple it is to pagenate the articles.
There's other code to access them but this is just to give you a taste and see if
there's any real interest in this.

This is placed after we got the message ie $message = $item;


......



Ahh... You mean "Paginate" thats how my download code works for the code tag. It numbers each code tag converted so the DIV's ID= will have a special ID so a javascript can pull the HTML from the code tag and print it in a pop-up window.



My generic signature.
Conectado
       

  Pagenated Articles?
  Ideas
  Foros
  
Páginas: [1]
Saltar a: