TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: ALL
from: ROWAN_CROWE
date: 1996-03-27 05:59:00
subject: CHR$() in string constants

Howdy everyone. Are there any plans for PowerBASIC to support CHR$() within a 
string constant? That is, being able to embed CHR$(13) or CHR$(27) without 
having to explicitly use CHR$. *OR* have CHR$(numerical constant) evaluated 
at compile time.
A source line such as:
    a$ = chr$(27) + "[33m" + chr$(13)
disassembles to:
    mov    ax,001B      ; CHR$(27)
    call   far [083C]   ; CHR routine?
    mov    bx,0000      ; save a byte and do XOR BX,BX
    call   far [0454]   ; concaneatate string routine?
    call   far [0374]   ;      "          "       "
    mov    ax,000D      ; CHR$(13)
    call   far [083C]   ; CHR routine?
etc.
But, this evaluation can be done at compile time. Benefits: faster, and 
smaller.
MoonRock does it like this:
    a$ = "\x1b[33m\x0d"
          ^^^^    ^^^^
        CHR$(27)   ||
                CHR$(13)
Cheers.
---
---------------
* Origin: Jelly-Bean software development, Melbourne AUST. (3:635/727.1)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.