Esta página es editable

Gleduwiki GnomeRSVP

De Gleducar, http://www.gleducar.org.ar

Esta página fue revisada y cumple los estándares de Gleduwiki.

  1. !/usr/bin/perl
  2. addpsx
  3. Generates addition worksheets in PostScript. Variable number of digits.
  4. This program is Copyright 1998 by Larry Doolittle.
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. If you do not have a copy of the GNU General Public License write to
  14. the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
  15. MA 02139, USA.
  16. You can reach Larry Doolittle as <weparent@widomaker.com>
  17. The "master" site for this program is
  18. http://www.widomaker.com/~weparent/oses.html
  19. Usage: addpsx <digits> | lpr
  20. Many parameters (e.g., size and spacing) are easily adjusted in the
  21. initialization section of this program.

$version="0.01";

if ($#ARGV < 0) {

 print STDERR "usage: addpsx <digits> | lpr\n";
 exit 1;

}

  1. Overall size

$pointsize=16; $vskip=18; $digits=int($ARGV[0]); if ($digits<1 || $digits>4) {

  die "usage: addpsx <digits> | lpr\n digits must be between 1 and 4\n";
  exit 1;

}

  1. Lateral spacing

$quescol=40; $colsep=60;

  1. Vertical spacing

$vstart=-90; $bottomskip=-450;

  1. Derived quantities

$dwidth=$pointsize*0.6; $hlsize=$dwidth*(2+$digits); $vskip2=0.7*$vskip; $vskip3=0.9*$vskip; $vskip4=1.8*$vskip; $lwidth=0.03*$vskip; $v2start=$vstart+$pointsize;

  1. Adjustments to primary quantities

$quescol+=($digits+2)*$dwidth; $colsep+=($digits+2)*$dwidth;

$gcos = (getpwuid($<))[6];

sub ps_digits { my $i; printf "LF "; for $i (reverse unpack ("C*",pop @_)) { $i=65 if $i==32; # space printf "d%c ",$i; } print "CR\n"; # printf "(%s)L\n",(pop @_); }

$now=localtime();

print <<EOF; %!PS-Adobe-2.0 EPSF-2.0 %%Creator: Larry Doolittle %%CreationDate: $now %%DocumentFonts: Helvetica %%Pages: 1 %%BoundingBox: 0 0 612 792 %%EndComments /Larrydict 20 dict def Larrydict begin /R {currentpoint stroke moveto

 dup stringwidth pop neg 0 rmoveto show } def

/L {exch dup F exch moveto exch R -$vskip add} bind def /S {$vskip2 add newpath dup F -$hlsize add exch moveto

                  dup F exch lineto stroke -$vskip3 add} bind def

/LF {dup F -$dwidth add exch moveto} bind def /CR {-$vskip add} bind def /A {gsave show grestore -$dwidth 0 rmoveto} bind def /d0 {(0)A} bind def /d1 {(1)A} bind def /d2 {(2)A} bind def /d3 {(3)A} bind def /d4 {(4)A} bind def /d5 {(5)A} bind def /d6 {(6)A} bind def /d7 {(7)A} bind def /d8 {(8)A} bind def /d9 {(9)A} bind def /dx {(x)A} bind def /d+ {(+)A} bind def /dA {( )A} bind def end %%EndProlog

%%Page: 1 1 Larrydict begin gsave /Helvetica findfont $pointsize scalefont setfont $lwidth setlinewidth 90 rotate

EOF

$vpos=0; print "$vstart /F $quescol def\n"; for $i (1..40) { chomp(); if (1) { $a=int(rand(10**$digits)); $b=int(rand(10**$digits)); } else { $a=8; $b=int(rand(10)); if (rand(2)<1) { $t=$a; $a=$b; $b=$t; } } # ($a,$b)=split(); $t=$a+$b; ps_digits($a); ps_digits("+ ".$b); print "S\n"; # ps_digits($t); # don't print answer ps_digits(""); # skip a line instead print "-$vskip4 add\n"; $vpos+=3*$vskip+($vskip3-$vskip2)+$vskip4; if ($vpos > $vstart-$bottomskip) { $vpos=0; $quescol+=$colsep; print "pop $vstart /F $quescol def\n"; } } print <<EOF;

pop

grestore end showpage %%Trailer EOF

Copyright © 2002-2010 Asociación Civil Gleducar
Todo los contenidos de este sitio se encuentran bajo una licencia libre del tipo Copyleft
Este sitio ha sido desarrollado usando Software Libre y respeta los estándares web.
Además ha sido diseñado para verse correctamente usando cualquier navegador, en cualquier resolución de pantalla.