There are curly braces in my COBOL output - cobol

My output in my latest 85 program has displays curly braces after the variables and im wondering why this is.
ex: - TOTALS: BEGN-BAL:00100000{ PAYMNT:0000300{ PURCHS:0002500{ FIN-CHRGE:001659{

actually
{ -> indicates +ve sign and
} -> indicates -ve sign
example: for +10 -->in program take s9(02) --> output: " 1{ "
example: for -10--> in program take s9(02) output-> " 1} "
SIGN - WILL BE STORE IN LAST DIGIT AS A CHARACTERS.

Related

Google Sheets SUBSTITUTE formula for creating an image path

I'm using the following ARRAYFORMULA to create an image path:
=ARRAYFORMULA(
if(row(A:A)=1,"#Icon",IF(
B:B="",,SUBSTITUTE(
"../../../../../../_Assets/Icons/"& LOWER(B:B&".png"), " ", "_")
)
)
)
What it does
Adding a path before the text and replaces all spaces with an underscore '_'. Here is an example:
Name
#icon
A Tit(l)e
../../../../../../_Assets/Icons/a_tit(l)e.png
Title - Subtitle
../../../../../../_Assets/Icons/title _-_subtitle.png
Title text/string - Subtitle
../../../../../../_Assets/Icons/title_text/string _-_subtitle.png
What I want it to do
If possible, I would like to achieve the following:
Avoiding/removing characters in the list below like the forward slash / with an underscore _ (see the last row in my example above)
It allready replaces all white spaces with an underscore _ which is good. But when it sees a whitespace followed by a - and another whitespace it will output _-_ but then I want only a -
So the current table above would output the following instead:
Name
#icon
A Tit(l)e
../../../../../../_Assets/Icons/a_tit(l)e.png
Title - Subtitle
../../../../../../_Assets/Icons/title-subtitle.png
Title text/string - Subtitle
../../../../../../_Assets/Icons/title_text_string-subtitle.png
List of characters to be avoided/replaced with an underscore _:
# pound
% percent
& ampersand
{ left curly bracket
} right curly bracket
\ back slash
< left angle bracket
> right angle bracket
* asterisk
? question mark
/ forward slash
blank spaces
$ dollar sign
! exclamation point
' single quotes
" double quotes
: colon
# at sign
+ plus sign
` backtick
| pipe
= equal sign
Any help/suggestion would be much appreciated!
Put list of avoided chars into column and use REGEXREPLACE:
=ARRAYFORMULA(if(row(A:A)=1,"#Icon",IF(A:A="",,"../../../../../../_Assets/Icons/"&LOWER(REGEXREPLACE(REGEXREPLACE(A:A," - ","-"),TEXTJOIN("|\",0,D2:D23),"_")) & ".png")))
try:
=ARRAYFORMULA({"#Icon",
IF(B2:B="",,SUBSTITUTE(SUBSTITUTE(
"../../../../../../_Assets/Icons/"&LOWER(B2:B&".png"), " ", "_"), "_-_", "-", 1))})

LUA string, drop non alphanumeric or space

I have customer input that may include letters, digits or spaces. For instance:
local customer_input = 'I need 2 tomatoes';
or
local customer_input = 'I need two tomatoes';
However, due to the nature of my application, I may get #, *, #, etc, in the customer_input string. I want to remove any non alphanumeric characters but the space.
I tried with these:
customer_input , _ = customer_input:gsub("%W%S+", "");
This one drops everything but the first word in the phrase.
or
customer_input , _ = customer_input:gsub("%W%S", "");
This one actually drops the space and the first letter of each word.
So, I know I am doing it wrong but I am not really sure how to match alphanumeric + space. I am sure this must be simple but I have not been able to figure it out.
Thanks very much for any help!
You may use
customer_input , _ = customer_input:gsub("[^%w%s]+", "");
See the Lua demo online
Pattern details
[^ - start of a negated character class that matches any char but:
%w - an alphanumeric
%s - a whitespace
]+ - 1 or more times.

How to know if a string contains substring with special symbols?

why this code:
p="PS02 - Fretted stereo2stereo (x86)" 
s="PS02 - " 
if string.match(p,s) then 
reaper.ShowConsoleMsg("Yes!")
end
gives us "Yes!"
But this Code:
p="PS02 - Fretted stereo2stereo (x86)" 
s="PS02 - F" 
if string.match(p,s) then 
reaper.ShowConsoleMsg("Yes!")
end
gives us nothing??
How to know if some string contain another (with whitespaces or another symbols like "-" or "()")?
"PS02 - " works appears to work because it's actually matching only the substring "PS02 ". This is because the - in (space)- means "match (space) zero or more times, but as few times as possible."
Magic characters ^$()%.[]*+-? must each be prefixed (escaped) with a leading %... so the correct patterns in each case above are "PS02 %- " and "PS02 %- F".

iOS accessibility, how to speak marks within text?

There are some marks just like exclamation mark or question mark, and I found iOS escape them by default. How to speak them out?
Example: 'Tom! First name' or '? My last account'.
You can speak these words to add these marks.... just check
apostrophe ‘
open bracket [
close bracket ]
open parenthesis (
close parenthesis )
open brace {
close brace }
open angle bracket <
close angle bracket >
colon :
comma ,
dash -
ellipsis …
exclamation mark !
hyphen –
period / point / dot / full stop .
question mark ?
quote "
end quote "
begin single quote '
end single quote '
semicolon ;
Typography Result
ampersand &
asterisk *
at sign #
backslash \
forward slash /
caret ^
center dot ·
large center dot •
degree sign °
hashtag / pound sign #
percent sign %
underscore _
vertical bar |

Token in JavaCC: make sure that a symbol is single on a line

I need "{" will be single on a line. Therefore I have to use a token that recognize it. This are right examples:
program
{
or
program
{
And this are incorrect examples:
program {
or
program
{ sentence;
Then I have a token like this:
TOKEN: { < openKey: "{" > {System.out.print(image +"\n");}}
SKIP: { < ( " " | "\r" | "\t" | "\n" )+ > }
But I can not think how to make the symbol "{" is exactly between one or more "\n". And after recognized it I have to write exactly:
program
{
If I try:
TOKEN: { < openKey: ( " " | "\r" | "\t" | "\n" )+ "{" ( " " | "\r" | "\t" | "\n" )+ > {System.out.print(image +"\n");}}
This runs but it writes so many "\n" like there was in the input.
The basic problem is that you're printing the input without any interpretation. In other words, what goes in is what comes out, as you've discovered.
To make it easier to read --- and in order to not be in some respects misusing the lexical analyzer by forcing it to do the entire task --- I recommend moving your print statement down into the parser (e.g., in the Start() function). (I actually tend to move all of my output out of the parser entirely unless I'm doing something really tiny that I'm never going to reuse, but that's for another question.)
Next, to address the actual problem, you have do some interpretation to get from a bunch of newlines to just one. The simplest way to do that is a basic replaceAll. Here's my Start() function, where openKey is defined just as you've done, and WORD is simply a concatenation of letters.
void Start() :
{
Token t;
}
{
(
t = <WORD>
{System.out.print((t.image).replaceAll("(\n)+","\n"));}
)*
(
t = <openKey>
{System.out.print((t.image).replaceAll("(\n)+","\n"));}
(
t = <WORD>
{System.out.print((t.image).replaceAll("(\n)+","\n"));}
)*
)*
<EOF>
}
So basically, this takes zero or more words, followed by the unit that consists of 1 or more newlines followed by the left curly brace followed by 1 or more newlines, followed by zero or more words, and outputs the words, the curly brace, and just 1 newline per 1-or-more-newline set.
If you can start a file with a curly brace, instead of requiring a word, then it outputs and empty line, a curly brace, and a newline. I don't know if that's what you want, being able to begin the output with an empty line, so you will need to play with the output code to get the exact formatting you're going for, plus, as you can see you've got some very nice repeated code in there that could be extracted into a function, so I leave that for an exercise for the reader.
Anyway, the basic premise of this answer is --- and I believe this is really something a maxim for the ages, suitable for use in all areas of life, not just coding --- "Unless you change what you take in before outputting it, it's going to be exactly what you took in!"
I did it differently:
TOKEN: { < openKey: "\n" (" " | "\t")* "{" (" " | "\t")* ("\r" | "\n") >{System.out.print("{\r\n");}}
SKIP: { " " | "\r" | "\t" | "\n" }
There were some problems with the carriage return, but this way works well.

Resources