How to create a file with two entries in COBOL? - cobol

I have two files, the first one has the date and the second one has multiple registers.
I want to create something like this:
Input File 1:
20200509
Input File 2:
0000001
0000002
0000003
Output
202005090000001
202005090000002
202005090000003
Thank u.

Build a record of two fields. I will not give you picture clauses.
Read file one and populate field one. (end of field one stuff).
Read file two and for each record, populate field two and write an output record.
Field one never changes?
Look into JOINKEYS (FILL?) if you get a moment and your shop has it.
And the record in File one should probably be a parameter.
Yes you will need to open and close the files, use filestat, and understand what a priming read is.
If you don't mind bad style and ANS COBOL c. 1972 see
https://github.com/mckenzm/join2files/blob/main/stackex1.cbl
(No filestat, no exception (empty file) handling.)

Related

ztree loaded table: How to match variables

I am trying to match data in an experiment, created through individual input, to a payoff structure that is stored in a txt I have (successfully) loaded into zTree before.
However, I do not know, how to find the - in specific - payoff to the corresponding input in the txt file that is defined there.
The txt file looks as follows:
NK table screenshot
Within the game, the "Input" variable is generated by users and now the payoff needs to be found corresponding to the input generated. Can anyone help out here?
Thanks a lot in advance!
TABLENAME.find(condition, variable) function retrieves the first value that fits a condition.
Assuming the user has the variable MyInput in the subjects table, this program running on subjects would do the trick:
NKtable.find(Input == :MyInput, Payoff)

Syntax to extract variable labels from SPSS file

I have hundreds of SPSS .sav files. For each one I want to extract the variable NAMES and variable LABELS as a two column table to a csv file. I know that this is straightforward by simply copying and pasting from the "Variable view" window, but I would really like to know how to do this using syntax. Is this possible?
Many thanks in advance for any help!
You might be interested in the GATHERMD extension command, It takes a wildcard for the file names and builds a dataset with three variables: the file name, the variable name, and the variable label. You could then just save that as a csv file.
This command requires the Python Essentials available with your Statistics installation or via the SPSS Community website (www.ibm.com/developerworks/spssdevcentral).
Using native Statistics syntax, DISPLAY DICTIONARY and CODEBOOK might be helpful, but they won't give you all this information in one table.

Generating values for dropdown ONLY for 'C' of CRUD

When choosing 'Add' in CRUD, how best to generate a list of choices to pick from a dropdown?
For U/update - just display what's there...
The field contents starts with a letter, followed by five numeric digits:{A-I,K-N,Z}#####
Each letter has a different 'max' value for the numeric part.
So when adding a new record, I'd like to offer a listbox with one of each letter and that letter's highest numeric value + 10.
So, if the max 'A' as A00120, and max 'B' B00030 (etc) the listbox would have A00130 and B00040.. etc
Save the user having to figure out which is 'next' when generating a new record.
? Thanks,
Mark
This time I'll not be able to come up with ready to use solution, but I must say - everything is possible with ATK4. You just have to customize and extend it to fit your needs :)
Speaking about your question above - I guess you have to split it in multiple parts.
First part is about how to show select box on Create and readonly or disabled field on Update. I guess you can make some custom Form field or pin some action to existing Form Field hook. Not sure exactly what's better in this case.
Second one is about data structure. I believe that this field actually should be 2 fields in DB and maybe (only maybe) merged together in ATK model with addExpression() just for user interface needs to display these 2 fields as one field easily in UI. Maybe such concatenated field will be useful also for searching, but definitely not as only one field stored in DB. Imagine how hard it'll be for DB engine to find max value if such field. Store it like type = letter, num = number and then search like SELECT max(num)+10 FROM t WHERE type='A'
Finally Third part is about how to generate this next number. I read your question 3 times and came to conclusion that actually you don't have to show this +10 numeric value in UI at all if it's hardly predefined anyway. Actually that'll not work correctly if this will be multi-user system which I guess it will. Instead just show simple select box with letters {A-I,K-N,Z} and calculate this next value exactly before inserting data in DB. That can be done using models insert hook. This will be much more appropriate solution and will be better for UI and also more stable because calculated in model not incorrectly in UI part.

Text File Index?

Good afternoon,
I am wanting to create a a Text file with a many different paragraphs. I want to show a different one everyday. Is there a way to create s sort of index and display a new paragraph each day?
I crated the app already, and the way I am updating is by going into my server and editing the text file and then downloading it into the app, and I have to update it every day and I don't want to do that anymore. I have about 2 years worth of daily paragraphs that I can simply have them all in a text file. I'm not sure if an index is the right approach to this.
I want to be able to have like a huge list of text paragraphs and then displaying a different one each day. Is there any way to do this? I am open to different suggestions! I just want to get it to work! Maybe someone can guide me through the right path.
Thank you!
First, start with the simplest thing that could possibly work:
Make a text file with all your paragraphs. Download the entire file into your app. In your app, split the file into paragraphs, choose one at random, and display it.
Now, if the above proves too slow, then consider optimising it. You could:
After downloading the text file (the first time), read through the file once and create an index with the offset of the start of each paragraph. Then, choose an index entry at random, seek to that point in the text file, read the paragraph, and display it.
Or, you could:
Create the index on the server and download it along with the text file. That saves the app from having to create the index itself.
There are probably easier/better ways to do this, but here's what I'd do...
I'd reorganize your text file into a CSV with two columns. The column on the left has the date paragraph should be displayed (in an easy to parse format), and the column on the right has the actual paragraph. When the app is first launched, it goes to the web, downloads and parses this whole file.
In your app, store these paragraphs in an NSDictionary, using the date as the key, and the paragraph as the value.
Now encode this NSDictionary to disc.
From now on, you don't need to redownload/reparse the file. You can just check in that dictionary, find the entry with the right date, and display that.
Now, ideally, you'd want your server to be able to tell your app when the file was last updated, and for your app to keep track of when it last downloaded the file. Any time the server's last update date is more recent than the app's last download date, the app should redownload, reparse, resave the file.
If you don't want to store the dates, you can simple put the paragraphs in a line separated .txt file. When you read the file in, you can store each paragraph into a separate array index very simply by doing something like this:
NSArray *paragraphs = [myTextDocContents componentsSeparatedByCharactersInSet:
[NSCharacterSet newLineCharacterSet]];

Automatically updating Data Validation lists based on user input

I have a very large data set (about 16k rows). I have 10 higher level blocks and within each block I have 4 categories (10 rows for each) which use Data Validation lists to show items available in each category. The lists should automatically update based on user input. What I need your help with is that I want to use the same data set for each block and preferably a least calculation/size intensive approach. I have put together a sample file that outlines the issue with examples.
Sample File
Thank you for your help in advance.
Okay, I've found something, but it can be quite time consuming to do.
Select each range of cells. For instance, for the first one, select B3:B18 and right click on the selection. Find 'Name a Range..." and give it the name "_FIN_CNY". Repeat for all the other ranges, changing the name where necessary.
Select the first range of cells to get the data validation, and click on "Data validation", pick the option "Allow: List" (you already have it) and then in the source, put the formula:
=INDIRECT($G$4&"_CNY")
$G$4 is where the user will input. This changes as you change blocks.
_CNY is the category. Change it to _CNY2 for the second category.
Click "OK" and this should be it. Repeat for the other categories.
I have put an updated file on dropbox where you can see I already did it for the data of _FIN for categories CNY, CNY2 and INT and did the one for _GER as well. You'll notice the category of INT for _GER doesn't work, that's because the Named Range _GER_INT doesn't exist yet.

Resources