New Constants...

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
plouf
Enthusiast
Enthusiast
Posts: 281
Joined: Fri Apr 25, 2003 6:35 pm
Location: Athens,Greece

Post by plouf »

Nice! what about:

Code: Select all

#DOUBLEQUOTE$ = Chr(34)
i needed this loads the other day... :)
serieously there are 32 special chatracter if we do the start why
nopt covere them all ?
NULL ,ACK etc
Christos
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Post by Danilo »

Code: Select all

#NUL$   = Chr(000)  :  #NUL =   0 ;    (NULL)
#SOH$   = chr(001)  :  #SOH =   1 ;    (Start of Header)
#STX$   = chr(002)  :  #STX =   2 ;    (Start of Text)
#ETX$   = chr(003)  :  #ETX =   3 ;    (End of Text)
#EOT$   = chr(004)  :  #EOT =   4 ;    (End of Transmission)
#ENQ$   = chr(005)  :  #ENQ =   5 ;    (Enquiry)
#ACK$   = chr(006)  :  #ACK =   6 ;    (Acknowledgment)
#BEL$   = chr(007)  :  #BEL =   7 ;    (Bell)
#BS$    = chr(008)  :  #BS  =   8 ;    (Backspace)
#HT$    = chr(009)  :  #HT  =   9 ;    (Horizontal Tab)
#LF$    = chr(010)  :  #LF  =  10 ;    (Line Feed)
#VT$    = chr(011)  :  #VT  =  11 ;    (Vertical Tab)
#FF$    = chr(012)  :  #FF  =  12 ;    (Form Feed)
#CR$    = chr(013)  :  #CR  =  13 ;    (Carriage Return)
#SO$    = chr(014)  :  #SO  =  14 ;    (Shift Out)
#SI$    = chr(015)  :  #SI  =  15 ;    (Shift In)
#DLE$   = chr(016)  :  #DLE =  16 ;    (Data Link Escape)
#DC1$   = chr(017)  :  #DC1 =  17 ;    (Device Control 1) (XON)
#DC2$   = chr(018)  :  #DC2 =  18 ;    (Device Control 2)
#DC3$   = chr(019)  :  #DC3 =  19 ;    (Device Control 3) (XOFF)
#DC4$   = chr(020)  :  #DC4 =  20 ;    (Device Control 4)
#NAK$   = chr(021)  :  #NAK =  21 ;    (Negative Acknowledgement)
#SYN$   = chr(022)  :  #SYN =  22 ;    (Synchronous Idle)
#ETB$   = chr(023)  :  #ETB =  23 ;    (End of Trans. Block)
#CAN$   = chr(024)  :  #CAN =  24 ;    (Cancel)
#EM$    = chr(025)  :  #EM  =  25 ;    (End of Medium)
#SUB$   = chr(026)  :  #SUB =  26 ;    (Substitute)
#ESC$   = chr(027)  :  #ESC =  27 ;    (Escape)
#FS$    = chr(028)  :  #FS  =  28 ;    (File Separator)
#GS$    = chr(029)  :  #GS  =  29 ;    (Group Separator)
#RS$    = chr(030)  :  #RS  =  30 ;    (Request to Send)(Record Separator)
#US$    = chr(031)  :  #US  =  31 ;    (Unit Separator)

#DEL$   = chr(127)  :  #DEL = 127 ;    (delete)


#NULL$  = Chr(000)                ;    (NULL)
#TAB$   = Chr(009)  :  #TAB =   9 ;    (TAB)

#CRLF$  = Chr(13) + Chr(10)
#LFCR$  = Chr(10) + Chr(13)

#DOUBLEQUOTE$ = chr(34)
#DQUOTE$      = chr(34)
More needed?
cya,
...Danilo
...:-=< http://codedan.net/work >=-:...
-= FaceBook.com/DaniloKrahn =-
User avatar
jqn
User
User
Posts: 97
Joined: Fri Oct 31, 2003 3:04 pm

Post by jqn »

... YES :!:

When I create a HTML page from a PB program, I need to change every vowel with accent (in spanish) and every special character, by the HTML value. (Character Entity Reference)

#AACUTE = "á"
#NTILDE = "ñ"
#QUOT = """
#AMP = "&amp:"
...

I need to include all constants, and use them in final page.

BR
joaquin
User avatar
jqn
User
User
Posts: 97
Joined: Fri Oct 31, 2003 3:04 pm

Post by jqn »

SORRY.

Html in forum message has changed my example:

#AACUTE = "&aacute"
#NTILDE = "&ntilde"
#QUOT = "&quot"
#AMP = "&amp"

(missing semicolon for reading purposes)

BR
joaquin
User avatar
Danilo
Addict
Addict
Posts: 3036
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Post by Danilo »

I think HTML isnt related to PB in any way, but you can add
this constants at the top of your project.
Adding standard ASCII chars should be enough, because its
directly related to PB.

But maybe the boss wants to add HTML stuff too... Fred :?:

(The bigger the Residents are, the longer it takes to start the compiler...)
cya,
...Danilo
...:-=< http://codedan.net/work >=-:...
-= FaceBook.com/DaniloKrahn =-
TronDoc
Enthusiast
Enthusiast
Posts: 310
Joined: Wed Apr 30, 2003 3:50 am
Location: 3DoorsDown

Post by TronDoc »

Danilo wrote:

Code: Select all

....
More needed?
those seem most appropriate.
Froggerprogger wrote:What about:

Code: Select all

#IDONTKNOWTHENAMEFORITSOICALLITJUSTTHE_Y_WITHTWODOTSABOVEIT$ = Chr(255)
:lol:
peace
[pI 166Mhz 32Mb w95]
[pII 350Mhz 256Mb atir3RagePro WinDoze '98 FE & 2k]
[Athlon 1.3Ghz 160Mb XPHome & RedHat9]
guido
User
User
Posts: 14
Joined: Tue Nov 25, 2003 4:56 pm
Location: Old Europe - Germany

Pre-canned constants are a suboptimal solution

Post by guido »

While of course having a resident file containing all that stuff is a solution, the example in a previous reply already showed, that the control character is not the final destination but an intermediate one like in

"text1" + #CR + "text2"

There is also not much advantage of looking up a value in a constant name table compared to an ASCII/UNICODE/HTML table. I would prefer syntactic support for embedding arbitrary hex codes like C does with the "\xHH" syntax. (Whether all that \a, \t, \n special cases are a bonus is another discussion). To ensure downward compatibility a different enhanced text delimiter (at least at the beginning) would be nice, like x", so the example would transform to x"text1\x0Dtext2".
Last edited by guido on Thu Jan 08, 2004 8:44 am, edited 1 time in total.
guido
freedimension
Enthusiast
Enthusiast
Posts: 613
Joined: Tue May 06, 2003 2:50 pm
Location: Germany
Contact:

Post by freedimension »

Full Ack but for the x"", that's some ugly code.
I would prefer compiler directives like CompilerEscapeCharactersOn and CompilerEscapeCharactersOff (default). That should be implemented very easy and fast.
johndehope3
New User
New User
Posts: 9
Joined: Tue Jan 13, 2004 7:00 am

Post by johndehope3 »

Umlaut
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Danilo, please add 1 more, conditional on platform...

Post by USCode »

Hi Danilo,
:idea: Please add a "new line" constant, something like "#NL$".
This would be a NEW LINE constant.

On Windows this constant should be:
#NL$ = Chr(13) + Chr(10)

On Linux it should be:
#NL$ = Chr(10)

This would be nice for those of us that need to write cross-platform software and need to insert a new line into our strings.

Thanks!
Post Reply