Enhancements to EDIT$(expr,flags) function:
• | Add new flags &h0040 (unquote) and &h0080 (exempt quoted characters). |
• | Define symbols in ashell.def for the various EDIT$ flags: |
Symbol |
Value |
Description |
---|---|---|
EDITF_SPTB |
&h0002 |
remove spaces and tabs |
EDITF_CTLS |
&h0004 |
remove chr(127) & chr(0)-chr(31) except TAB |
EDITF_SPTBL |
&h0008 |
remove leading spaces and tabs |
EDITF_SPTB1 |
&h0010 |
shrink spaces & tabs to one space |
EDITF_SPTBR |
&h0020 |
remove trailing spaces and tabs |
EDITF_UNQT |
&h0040 |
unquote (and reduce "" to "). EDITF_UNQT performs two operations: 1) if the first and last character, after any other processing (such as removal of leading/trailing spaces and tabs) are both double quotes ("), then are removed. 2) Any remaining double double-quotes ("") which are not preceded by a single double-quote are reduced to a single double-quote ("), unless the string has been reduced to a single pair of double double-quotes (""). |
EDITF_EXQT |
&h0080 |
limits action to outside matched quotes. Exemption for quoted strings allows for multiple quoted subsections. This works well with JSON documents, which may contain many individually quoted strings, yet it may be convenient to remove all the whitespace not within those quoted strings. |
Examples
S$ After EDIT$(S$,EDITF_SPTB+EDITF_EXQT)
--------------------- ------------------------------------------
"name" : "v1 v2" "name":"v1 v2"
"name" : v1 v2 "name":v1v2
"name : v1 v2" ] "name : v1 v2"]
"6"" ruler" "6"" ruler"
S$ After EDIT$(S$,EDITF_UNQT)
--------------------- ------------------------------------------
"6"" ruler" 6" ruler
"6"" ruler":$1.99 "6"" ruler":$1.99
In the last example above, the outer quotes were not removed because they didn't completely enclose the string, and the "" was not reduced to " because it followed a " character.