File: LocTextRider.Mod

package info (click to toggle)
oo2c32 1.5.0-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 8,748 kB
  • ctags: 5,415
  • sloc: ansic: 95,007; sh: 473; makefile: 344; perl: 57; lisp: 21
file content (98 lines) | stat: -rw-r--r-- 3,061 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
(*	$Id: LocTextRider.Mod,v 1.3 1999/09/02 13:11:04 acken Exp $	*)
MODULE LocTextRider;

(*
    LocTextRider - localized text riders.
    Copyright (C) 1997 Michael Griebling
 
    This module is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as 
    published by the Free Software Foundation; either version 2 of the
    License, or (at your option) any later version.
 
    This module is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
    License along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*)

IMPORT Conv:=ConvTypes, LocNumConv, LocNumStr, TextRider;

TYPE
  Reader * = POINTER TO ReaderDesc;
  ReaderDesc * = RECORD (TextRider.ReaderDesc)
  END;
  Writer * = POINTER TO WriterDesc;
  WriterDesc * = RECORD (TextRider.WriterDesc)
  END;
 
PROCEDURE (r: Reader) ReadMoney * (VAR money: LONGREAL);
(* Reads a localized money string into `money'. This method will
   work with both local and international money strings. *)
VAR
  str: ARRAY 64 OF CHAR; 
  cnt: INTEGER;
  class: Conv.ScanClass;
  state: Conv.ScanState;
BEGIN
  (* get the initial state *)
  r.ReadChar(str[0]); cnt:=1;
  LocNumConv.ScanMoney(str[0], class, state);

  (* scan for valid characters *)
  WHILE ~r.Eol() & (class#Conv.invalid) & (class#Conv.terminator) DO   
    (* get next character & state *)
    r.ReadChar(str[cnt]); INC(cnt);
    state.p(str[cnt], class, state)
  END;
  
  (* convert to a number *)
  str[cnt]:=0X; money:=LocNumConv.ValueMoney(str)
END ReadMoney;

PROCEDURE (r: Reader) ReadNumber * (VAR number: LONGREAL);
(* Reads a localized number string into `number'. *)
VAR
  str: ARRAY 64 OF CHAR; 
  cnt: INTEGER;
  class: Conv.ScanClass;
  state: Conv.ScanState;
BEGIN
  (* get the initial state *)
  r.ReadChar(str[0]); cnt:=1;
  LocNumConv.ScanNumber(str[0], class, state);

  (* scan for valid characters *)
  WHILE ~r.Eol() & (class#Conv.invalid) & (class#Conv.terminator) DO   
    (* get next character & state *)
    r.ReadChar(str[cnt]); INC(cnt);
    state.p(str[cnt], class, state)
  END;
  
  (* convert to a number *)
  str[cnt]:=0X; number:=LocNumConv.ValueNumber(str)
END ReadNumber;

PROCEDURE (w: Writer) WriteMoney * (money: LONGREAL; int: BOOLEAN);
(* Writes `money' as a localized money string when int is FALSE
   and as an international money string when int is TRUE. *)
VAR
  str: ARRAY 64 OF CHAR;
BEGIN
  LocNumStr.MoneyToStr(money, int, str); w.WriteString(str)
END WriteMoney;

PROCEDURE (w: Writer) WriteNumber * (number: LONGREAL);
(* Writes `number' as a localized number string. *)
VAR
  str: ARRAY 64 OF CHAR;
BEGIN
  LocNumStr.NumToStr(number, str); w.WriteString(str)
END WriteNumber;

END LocTextRider.