ASCII escape sequences...

Just starting out? Need help? Post your questions and find answers here.
GypsyPrince
User
User
Posts: 20
Joined: Sun Apr 05, 2015 9:13 pm

ASCII escape sequences...

Post by GypsyPrince »

I know two simple escape sequences in PB:
#TAB$ and #CRLF$

Could someone please direct me to a list of all of them? I've been using PB for 2 years now and haven't had to consult either the Help or the "PureBasic: Beginner's guite to Computer Programming" book up until this point. Neither seem to be of any help at all to me as both contain material you already know if you just think about it. And neither seems to contain any information that I don't know, like PB's constants for escape sequence. Anyway, can someone please list the rest of them for me, or point me to wherer I might find them?

Thanks!!

Also, is there a way to include an "Include" folder path in the options dialog for the compiler to use? I have a few include/module/class files that I use on pretty much every app, similar to the way C/C++ uses header files. It's REALLY annoying to have to copy and paste them into my current project folder with each new project. I should only have to create them once and create a link for the compiler to find them.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: ASCII escape sequences...

Post by ts-soft »

PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: ASCII escape sequences...

Post by Danilo »

GypsyPrince wrote:I know two simple escape sequences in PB:
#TAB$ and #CRLF$

Could someone please direct me to a list of all of them?
That's just predefined PB constants, not escape sequences for use within strings.

- German Forum FAQ: (PB) Nützliche Konstanten... die niemand kennt
GypsyPrince wrote:Also, is there a way to include an "Include" folder path in the options dialog for the compiler to use? I have a few include/module/class files that I use on pretty much every app, similar to the way C/C++ uses header files. It's REALLY annoying to have to copy and paste them into my current project folder with each new project. I should only have to create them once and create a link for the compiler to find them.
Make a "Include" directory within your PB directory, or use a global directory where you put your PB include files and libraries.
No need to copy it in every project directory (maintenance hell :D).

You could also make a /RESIDENT file and put it in your PB/Residents/ folder, out of the following or similar Macros:

Code: Select all

Macro _UseClassDQ_
   "
EndMacro

Macro UseClass(classname)
    XIncludeFile #PB_Compiler_Home + "Include\Classes\"+_UseClassDQ_#classname#_UseClassDQ_+".pbi"
EndMacro

Macro UseInclude(filename)
    XIncludeFile #PB_Compiler_Home + "Include\" + filename + ".pbi"
EndMacro

Macro Using(filename)
    XIncludeFile #PB_Compiler_Home + "Include\Classes\"+_UseClassDQ_#filename#_UseClassDQ_+".pbi"
EndMacro
Usage after installing the resident (.res) file:

Code: Select all

UseInclude("OOP_BASE")

Using(gDrawing)
GypsyPrince
User
User
Posts: 20
Joined: Sun Apr 05, 2015 9:13 pm

Re: ASCII escape sequences...

Post by GypsyPrince »

Thanks so much, guys!!

Actually, the PB Constants for the unprintable ascii control is what I was wanting. I guess I should have given a better description.
This is what I found:

#NUL$ = Chr(00) Null Character
#SOH$ = Chr(01) Start of Heading
#STX$ = Chr(02) Start of Text
#ETX$ = Chr(03) End of Text
#EOT$ = Chr(04) End of Transmission
#ENQ$ = Chr(05) Enquiry
#ACK$ = Chr(06) Acknowledgment
#BEL$ = Chr(07) Bell/Buzzer
#BS$ = Chr(08) Back Space
#HT$ = Chr(09) Horizontal Tab
#LF$ = Chr(10) Line Feed
#VT$ = Chr(11) Vertical Tab
#FF$ = Chr(12) Form Feed
#CR$ = Chr(13) Carriage Return
#SO$ = Chr(14) Shift Out/X-On
#SI$ = Chr(15) Shift In/X-Off
#DLE$ = Chr(16) Data Line Escape
#DC1$ = Chr(17) Device Control 1 (oft. XON)
#DC2$ = Chr(18) Device Control 2
#DC3$ = Chr(19) Device Control 3 (oft. XOFF)
#DC4$ = Chr(20) Device Control 4
#NAK$ = Chr(21) Negative Acknowledgement
#SYN$ = Chr(22) Synchronous Idle
#ETB$ = Chr(23) End of Transmit Block
#CAN$ = Chr(24) Cancel
#EM$ = Chr(25) End of Medium
#SUB$ = Chr(26) Substitute
#ESC$ = Chr(27) Escape
#FS$ = Chr(28) File Separator
#GS$ = Chr(29) Group Separator
#RS$ = Chr(30) Record Separator
#US$ = Chr(31) Unit Separator

#DQUOTE$ = Chr(34) Double Quote

I still can't find the PB constant for single quote/Chr(39) or for space/Chr(32). I know these are printable but they don't cooperate when putting inside quoted strings.
I've found #SPACEPARITY but doesn't seem to be the correct one.

I've read earlier posts where some people would like to use compounded single quotes or double quotes when dealing with strings. Bit then another poster/moderator pointed out that doing so could mess up queries. It would also be super nice if we could use the same escape sequences as we use in the C language. But from the examples I've been pointed to, it seems like a lot of overhead to use them.
Last edited by GypsyPrince on Mon Apr 06, 2015 12:08 am, edited 1 time in total.
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: ASCII escape sequences...

Post by Danilo »

GypsyPrince
User
User
Posts: 20
Joined: Sun Apr 05, 2015 9:13 pm

Re: ASCII escape sequences...

Post by GypsyPrince »

Danilo,

If I create the "include" folder within my PB folder, will the PB compiler automatically read it or do I need to set a path to it somewhere?
I guess I could put XIncludeFile "C:\PureBasic\include\module_name.pbi" at the head of each project without having to copy the file into each project's folder.
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

Re: ASCII escape sequences...

Post by Danilo »

GypsyPrince wrote:If I create the "include" folder within my PB folder, will the PB compiler automatically read it or do I need to set a path to it somewhere?
PB does not automatically include any paths or files. IncludePath sets the path.

Code: Select all

IncludePath #PB_Compiler_Home+"Include"
XIncludeFile "module_name.pbi"
GypsyPrince wrote:I guess I could put XIncludeFile "C:\PureBasic\include\module_name.pbi" at the head of each project without having to copy the file into each project's folder.
Yes. By using a compiled macro (/RESIDENT) you can shorten it to, for example:

Code: Select all

Using(module_name)
GypsyPrince
User
User
Posts: 20
Joined: Sun Apr 05, 2015 9:13 pm

Re: ASCII escape sequences...

Post by GypsyPrince »

Awesome sauce!!!

Thanks!!!
Dawgmann
User
User
Posts: 40
Joined: Wed Jul 17, 2019 5:32 pm

Re: ASCII escape sequences...

Post by Dawgmann »

Hello. I'm new to both PB and this forum. I know this is an old thread but I ran across it in search of some info.

In reference to Danilo's response to another poster:

"PB does not automatically include any paths or files. IncludePath sets the path."

It is my understanding from reading this interaction that, currently, there is not a way to add a path for an "include" folder in PB options whereby the compiler will search within that folder (and its subfolders) for any files indicated in the staement XIncludeFile "module_name.pbi", and that the statement IncludePath #PB_Compiler_Home+"Include" must be included in each project.

Question 1:
Can someone confirm that my interpretation of this is correct?

Question 2:
Also, just for further clarity in case someone in the future has the same question...
- a.) Does IncludePath #PB_Compiler_Home+"Include" have to be at the head of every source file in the project?
- b.) Does it need to be only at the head of the source file in which a call to a procedure(s) in that external file is made?
- c.) Or, does it have to be at the head of only a single source file in the project, and it does not really matter which one?

Placing IncludePath #PB_Compiler_Home+"Include" in my projects isn't that big of a deal if it is required and I don't want to appear as "needy". I was just generally curious if there was a way to automate it as with some other IDEs.

Thanx!
Dawgmann
User avatar
skywalk
Addict
Addict
Posts: 3995
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: ASCII escape sequences...

Post by skywalk »

OK, get in the habit of prefixing your source code with relevant settings and include files.
Also, make the include path relative, so you can move your parent path anywhere.
Think multiple version testing.
Here is a template I use:
Not all include files require include files.
But, I do make sure all my include files can be compiled on their own.
Using a #LIB_TEST constant, I can then include any necessary include files within a CompilerIf block.
A main app always has a #MYAPP_TEST constant.
Once set to TRUE, you can debug either your entire app or just an include file.

Code: Select all

; COMPILER OPTIONS:
;   [ ] Main source file:
;   [ ] Use Compiler:   PureBasic 5.71b2 (Windows - x64)
;   [x] Use Icon:       C:\dev\myapp\img\myapp_16x16.ico
;   [ ] Enable inline ASM syntax coloring
;   [x] Create threadsafe executable
;   [x] Enable OnError lines support
;   [x] Enable modern theme support (for Windows XP and above)
;   [ ] Request Administrator mode for Windows Vista and above
;   [ ] Request User mode for Windows Vista (no virtualisation)
;   [ ] Enable DPI aware executable (Windows)
;   Library Subsystem:
;   Executable format:        Windows ;|Console|Shared DLL
;   CPU Optimisation:         All     ;|Dynamic|w/MMX|w/3DNOW|w/SSE|w/SSE2
;   Sourcefile Text encoding: UTF-8
; COMPILE/RUN:
;   [x] Create temporary executable in the source directory
; CONSTANTS:
; VERSION INFO/RESOURCES:
;   Update version info in:   C:\dev\myapp.rc
; IDE PREFERENCES:ToolsPanel:Configuration:Procedure Browser
;   [x] Sort Procedures by name       ;<-- Alphabetical instead of order of appearance. Uncheck when location of Proc desired.
;   [ ] Group Markers                 ;<-- If checked, ';-!' priority listing is lost.
;   [ ] Display Procedure Arguments   ;<-- Too busy if checked.
;-{ XINCLUDES
EnableExplicit
#MYAPP_TEST = 0;-! _SET TEST
CompilerIf #PB_Compiler_Version < 560 And #PB_Compiler_Processor <> #PB_Processor_x64
  MessageRequester("MyApp", "Incorrect compiler settings: PB >= v56b1 And x64.", #PB_MessageRequester_Error)
  End
CompilerEndIf
IncludePath  "..\"  ; Or #PB_Compiler_FilePath If Preferences-Compiler-Defaults [x] Create temporary executable in the source folder.
XIncludeFile "lib\lib1.pbi"
XIncludeFile "lib\lib2.pbi"
XIncludeFile "lib\lib3.pbi"
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Dawgmann
User
User
Posts: 40
Joined: Wed Jul 17, 2019 5:32 pm

Re: ASCII escape sequences...

Post by Dawgmann »

@Skywalker

Ha ha... I'll pretend that I'm at least halfway intelligent and that I understood portions of that.

But in reality, it all went waaaaaaaaaaay over my feeble head. LOL

I was just curious if the 'IncludePath' directive had to be included in all project files, a specific project file, or any single file at all when wanting to include an external file for compilation.
User avatar
skywalk
Addict
Addict
Posts: 3995
Joined: Wed Dec 23, 2009 10:14 pm
Location: Boston, MA

Re: ASCII escape sequences...

Post by skywalk »

Haha, yes I am a bit detailed in that reply.
But, do not confuse project files with source code files.
I am only talking about your source code files above.
(Project files are xml files that tell the IDE what to load and what targets to build, etc.
I do not use Project files for my design flow.)

So, yes, you should have xincludefile in each of your source files that is dependent on other code.
You only need includepath if you smartly choose relative xincludefile's. :wink:
The nice thing about standards is there are so many to choose from. ~ Andrew Tanenbaum
Post Reply