cobol difference with Picture having a dash (-) and a having a X - cobol

What are the differences between the 2 pictures below?
PIC X(15)
PIC ----,---,---.99.
Is the bottom just another way to represent the top?

PIC X(15) Represents 15 characters of virtually any type of data, could be
digits, letters or any other symbol (printable or not).
PIC ----,---,---.99 Represents a numeric edited data item capable of holding
values in the range +999999999.99 through -999999999.99. This item will display a leading minus sign if the
value placed into it is negative, otherwise it will display the number without a leading sign. The displayed
number will have comma separators at the indicated positions provided there is at least 1 digit in front of it.
Here are a few samples of the way certain numbers will display:
999999999.99 displays as 999,999,999.99
1234.56 displays as 1,234.56
0 displays as .00
-1234567.12 displays as -1,234,567.12
-3 displays as -3.00
Variables such as this are for display only. Don't even think
about doing arithmetic with them! Given the following data declarations:
01 DISP-NBR PIC ----,---,---.99.
01 NBR PIC S9(9)V99.
The following MOVE operations are both valid
MOVE 1234.56 TO NBR
MOVE 1234.56 TO DISP-NBR
However,
ADD 1 TO NBR
is perfectly valid but...
ADD 1 TO DISP-NBR
Will give you a compile error. Even though DISP-NBR contains numeric data it is in a display only
format. You need to do math using data items that are purely numeric and then MOVE them to display fields
for 'pretty printing'.
This table
describes all of the PICTURE elements that may be used in COBOL and what they are for.

The first one can have any alpha-numeric caracters.
The second one is used to format number. The dash means that if you have a negative number, a dash will be shown beside (at the left) of the number. Only one dash will be displayed. If the number is positive, a space will shown for every dashes.

Related

Google Charts API - QR code with leading zeros

I am inserting the following into cell A1 - generate a QR code from the text in both B1 and B2:
=image("https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=" & B1 & "%0A" & B2)
An example might be
B1= TAG
B2= 000000501
I am using a formula for other cells to add one to create an automatic number sequence based on the first value (e.g., B4=SUM(B2+1); B6=SUM(B4+1), etc.).
I would like the resultant QR scan to read "TAG000000501", but the leading zeros are not displayed (e.g., "TAG501". I know how to have the leading zeros displayed regularly by inserting an ' at the beginning of the number, or by changing the cell type to text or a special format with those six leading zeros. It seems the formula forces it to be a number in the API, which results in dropping the zeros.
Any ideas?
Thanks much for your time!
Try this:
=image("https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl=" & CONCAT(B1;REPT("0";9-LEN(B2));B2))

google sheet, position of first number in a string

BJ190215P00020000
this is the string. I want to extract the left letters "BJ" (they are from 1 letter up to letters).
I think i need to find the position of the first digit, then apply LEFT function to get out the "BJ". (the letters could be 1-8).
is there a way to find the position of first digit in the string. OR, is there a better way to extract the letters before the first digit?
Try ...
=regexextract(A1,"\D+")

Get all characters before a whitespace in LUA (ROBLOX)

I have a 5x5 grid of tiles that are number like:
Numerical order Row number(eg: 1 1 would be the first tile on the first row and 6 2 would be the first tile on the second row)
I need to get the blocks around a clicked tile (above, below, left and right), I thought about doing this by taking off numbers from the numerical order and row number. I wrote this:
local ab = tostring(tonumber(v.Name)-5)..tostring(tonumber(string.sub(v.Name,-1))-1)
local be = tostring(tonumber(v.Name)+5)..tostring(tonumber(string.sub(v.Name,-1))+1)
ab being the tile above and be being the tile below. I ran into a problem where I cannot get the first two letters of a tile who's numerical order is two digits using one line (I don't want to use if statements since I'm pretty sure there's a one line solution)
I came up with a solution and that is to get all the characters before the whitespace (which separates the order from the row number) but I have no idea how to write it.
Just ask for all non-whitespace characters from the beginning of the string:
print(("test123 more456"):match("^(%S+)"))
This should print test123.

Operations on the controls within the repeater control

A form in a Orbeon form builder contains a repeater control(new repeat).Suppose there are three text controls on each row(or repeat) of a repeater control(new repeat).first two text controls on each row contains numeric values.I want to bring the product of first two text controls to the third text control at run time without any event.there will be multiple numbers of repeat in the runtime ,i.e the row may increase but for each the calculation much reflect at runtime and for each row product of first two must be viewed on the third one
Name the fields in the first and second column (click on cog wheel to the right of the field). Say you picked the names quantity and price.
For the 3rd field, enter the following XPath expression in calculated value, all in one line (in the Edit Validation Properties you get by clicking on the red exclamation mark):
if ($quantity castable as xs:double and $price castable as xs:double)
then $quantity * $price
else 'n/a'
You refer to other controls by name, preceding the name by a dollar sign, and here we check that a value is indeed a number with $gaga castable as xs:double.

Cobol dashes are confusing me [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
cobol difference with Picture having a dash (-) and a having a X
I'm tying to get to grips with Cobol and can't understand the dashes when formatting a number. I have this example:
--9
Am I correct with the following?
The first dash - If number is a negative put a dash otherwise don't.
the second dash - I'm confused with this. There is already a dash at the start to specify whether its negative or positive.
9 - Numeric digit (0-9)
An example would be good. :S
Thanks
In view of your previous question, Im not sure what you are having trouble with. But lets try again...
In COBOL, numeric display fields may contain various types of "punctuation". This "punctuation" is defined in the items PICTURE clause. A few examples of the type of "punctuation" symbols you can use are: Explicit decimal points, plus/minus signs, CR/DR indicators and thousnads separators (commas in North America). There is a well defined set of rules that determine what type of "punctuation" can occur in the PICTURE clause and where. This link to PICTURE CLAUSE editing explains how to construct (or read) any given PICTURE clause.
One thing that you, and many others new to COBOL, trip up on is that a data definition in COBOL specifies two distinctly different types of information about numeric display data. One is the range of values it may hold and the other is how
that range of values may be displayed. Your example: PICTURE --9 tells me two things about the data item: 1) Values are integers in the range of -99 through to +99, and 2) Displaying this item will take 3 spaces. If the number is positive, spaces will appear before the first non zero digit. If the number is negative a minus sign will appear immediately to the left of the first non zero digit. Consider the following COBOL DISPLAY statement:
DISPLAY '>' DISP-NBR '<'
IF DISP-NBR has a PICTURE clause of: --9 this is how various values will be displayed.
0 displays as: > 0<
-1 displays as: > -1<
-11 displays as: >-11<
10 displays as: > 10<
Note that all displays take 3 character positions. At least 1 digit will always be displayed (because of the '9' in the PICTURE clause), other than that, no leading zeros are displayed. A minus sign will display only for negative values. The minus sign, if displayed will be to the immediate left of the first displayed digit.
Now to answer you specific question: The total number of character positions needed to display a numeric display data item is determined by the length of the PICTURE. You have a 3 character PICTURE so 3 character positions are needed. When
a sign is specified in the PICTURE, a space is always reserved for it. This is what limits the range of integers to those containing at most 2 digits. The second minus sign indicates 'zero supression'. Zero supression just means not printing leading zeros. Only 1 minus sign is ever printed and it will be to the immediate left of the first displayed digit.
COBOL contains a lot of flexability with respect to displaying numbers. Understanding the numeric display PICTURE clause is key to understanding how this all works.
from stackoverflow:cobol-difference-with-picture-having-a-dash-and-a-having-a-x
The dash means that if you have a negative number, a dash will be
shown beside (at the left) of the number. Only one dash will be
displayed. If the number is positive, a space will shown for every
dashes.

Resources