Re: [cc65] Two cc65 Ideas

From: Payton Byrd <plbyrd1gmail.com>
Date: 2012-01-30 21:31:52
<pipedream>
There is definitely a lot of power in doing this.  I wish we had a
text-based numeric library so we can treat string data like numbers as in
COBOL.  It could also get us round the lack of partial numbers in cc65.

Combine that with unions and we could do some cool stuff:

union value {
  char complete[11]; // $  4000.00
  struct {
    char sign;
    char number[9];
  } s;
} v1, v2, v3;
strcpy(v1.complete, "$    99.99");
strcpy(v2.complete, "$     0.01");
strcpy(v3.complete, "$         ");
v3.s.sign = '$';
v3.s.number = text_add(v1.s.number, v2.s.number, sizeof(v1.s.number) + 1,
sizeof(v2.s.number) + 1);

This would put "$   100.00" in v3.complete
Then we could do something like:
i = text_to_uint16(v3.s.number, sizeof(v3.s.number) + 1);

A **HUGE** benefit of doing this would be the ability to read long lines of
text from a file into a single union variable and parse it and use it like
COBOL does.
</pipedream>

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Jan 30 21:32:24 2012

This archive was generated by hypermail 2.1.8 : 2012-01-30 21:32:27 CET