Adding each text line to a stringlist in delphi - delphi

I have a text file thats about 53,000 lines. I wanted to put each line into a stringlist. for example I have:
2023/01/30,23:22:25, 0. 7. 5,SP60-1,03,Wait for post process,130000,Start at Wait for post process
2023/01/30,23:22:25, 0. 7. 5,SP60-1,04,Product 1board end,000000,Product 1board end
2023/01/30,23:22:14, 0. 7. 5,SP60-1,06,PCB carrying in,000000,PCB carrying in
2023/01/30,23:21:46, 0. 7. 5,SP60-1,06,PCB carrying in,000000,PCB carrying in
2023/01/30,23:21:46, 0. 7. 5,SP60-1,03,Wait for pre process,120001,Exit Wait for pre process
2023/01/30,23:21:28, 0. 7. 5,SP60-1,03,Wait for pre process,120000,Start at Wait for pre process
2023/01/30,23:21:28, 0. 7. 5,SP60-1,04,Product 1board end,000000,Product 1board end
2023/01/30,23:21:18, 0. 7.70,CM212-A1,03,Wait for post process,130000,Start at Wait for post process Stage No1, (Whole MC), (Single Lane), PCB ID:
2023/01/30,23:21:17, 0. 7.70,CM212-A1,04,Product 1board end,000000,Product 1board end Stage No1, (Single Lane), Present PCB Position:No1 mount position (conveyor), PCB ID:+044363D897206C+
2023/01/30,23:21:07, 0. 7.70,CM212-A1,03,Wait for post process,130000,Start at Wait for post process Stage No2, (Whole MC), (Single Lane), PCB ID:
2023/01/30,23:21:07, 0. 7.70,CM212-A1,28,Board available,000000,Board available Stage No2, (Single Lane), PCB ID: , BAON
2023/01/30,23:21:07, 0. 7.70,CM212-A1,04,Product 1board end,000000,Product 1board end Stage No2, (Single Lane), Present PCB Position:No1 mount position (conveyor), PCB ID:+044363D896DB6A+
2023/01/30,23:21:06, 0. 7. 5,SP60-1,06,PCB carrying in,000000,PCB carrying in
2023/01/30,23:21:06, 0. 7. 5,SP60-1,03,Wait for pre process,120001,Exit Wait for pre process
2023/01/30,23:21:04, 0. 7. 5,SP60-1,07,PCB carrying out,000000,PCB carrying out
2023/01/30,23:21:04, 0. 7. 5,SP60-1,03,Wait for pre process,120000,Start at Wait for pre process
2023/01/30,23:21:04, 0. 7. 5,SP60-1,04,Product 1board end,000000,Product 1board end
I am not sure how to define the "line", I would think there is a way for the stringlist to import the text file (actually its a .out file but its just text)
What is the best way to do this considering there is about 53k lines?
thanks

Related

FCEUX stops responding when i run this code made by me

--llama a IUP
require("iuplua")
--Variables
on= 1
puntos1=memory.readbyte(0x0007DE) --Read the points value
puntos2=memory.readbyte(0x0007DF)
puntos3=memory.readbyte(0x0007E0)
puntos4=memory.readbyte(0x0007E1)
puntos5=memory.readbyte(0x0007E2)
p1=puntos1*100000 --Convert the raw values to it's game value
p2=puntos2*10000
p3=puntos3*1000
p4=puntos4*100
p5=puntos5*10
maxpuntaje=p1+p2+p3+p4+p5 --Calculate the final result
mundo=memory.readbyte(0x00075F) --Read the "world" value
nivel=memory.readbyte(0x000760) --Read the "level" value
estado=memory.readbyte(0x000770) --Read the mario "state" (00 not in game, 01 playing, 03 game over)
--Escribir las variables anteriores al morir
memory.writebyte(0x00075A,00) --Change the "lives" value to 1
while(on==1) do
estado=memory.readbyte(0x000770)
print(estado)
print(type(estado))
if(estado==03)then
print("Puntuacion maxima (sesion actual) = ",maxpuntaje)
print("Mundo y nivel Actual: ",mundo+1,"-",nivel+1)
end
end
(code edited)
This is the state of 0x000770 when playing
This is the state of 0x000770 when the Game Over scene jumps in
is there anything wrong? fceux just stop responding when i run this script, im new at stacks overflow and at programming so, every help will be welcome
It's rather simple to debug this but more information is required
Make sure (estado==03) yields true and also print following variables and add into your question
mundo=memory.readbyte(0x00075F)
nivel=memory.readbyte(0x000760)
estado=memory.readbyte(0x000770)
print(mundo, nivel, estado)
Check the types of these memory read vaiables i-g print(type(mundo))
Make Sure that the if condition checks against correct types
You realize that memonry is read once and while is always true
Try this:
while(on==1) do
estado=memory.readbyte(0x000770)
print(estado)
print(type(estado))
if(estado==03)then
print("Puntuacion maxima (sesion actual) = ",maxpuntaje)
print("Mundo y nivel Actual: ",mundo+1,"-",nivel+1)
end
end
im so sorry for wasting your time, but i found the error, it was actually quite simple, there was a missing FCEU.frameadvance at the end of the cycle.
i dont know why it caused the emulator to crash but after putting it in place it stopped crashing. thanks to wsha for helping.

How to select cases based on criteria of several variables in SPSS?

In a dataset, there are 10 variables V1, V2,..., V10.
How can I select cases in which the value of any of those variables is greater or equal, say, 10?
I tried this but it didn't work:
temporary.
select if any(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, ge 10).
list id.
This and a couple of others didn't work either:
select if ((v1, v2, v3, v4, v5, v6, v7, v8, v9, v10) ge 10).
You could use VECTOR/LOOP approach here and specifying the loop to be exited as soon as the first variable meets the given criteria, in your case variable to be greater than value of 10, so to not unnecessarily continue looping over remaining variables:
*****************************************.
* set up dummy data.
set seed = 10.
input program.
loop #i = 1 to 500.
compute case = #i.
end case.
end loop.
end file.
end input program.
dataset name sim.
execute.
vector v(10, F1.0).
do repeat v = v1 to v10.
compute v = TRUNC(RV.UNIFORM(1,12)).
end repeat.
execute.
*****************************************.
vector v=v1 to v10.
loop i=1 to 10.
if (v(i) > 10) Keep=1.
end loop if v(i) > 10.
select if Keep.
You'll have to loop for it:
do repeat vr=v1 to v10.
if vr ge 10 KeepMe=1.
end repeat.
select if KeepMe=1.
This will also work:
count cnt_ = v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 (10 thru highest).
exe.
select if cnt_>0.
exe.
The cnt_variable is used for counting how many variables have a value of 10 or greater. Then the selection command selects what you need.
Also, don't forget about execute, to apply all pending transformations. Otherwise nothing will happen.

INSPECT verb in COBOL program

Here is an example I used for INSPECT verb.
INSPECT FUNCTION REVERSE (WS-ADDR(7:4)) TALLYING WS-COUNT FOR LEADING SPACES
DISPLAY 'COUNT :' WS-COUNT
COMPUTE WS-LENGTH = 4 - WS-COUNT
DISPLAY 'LENGTH :' WS-LENGTH
I am not getting the right output with the below input,
Input-1 - 43WE
WS-COUNT = 0
LENGTH = 4
Input-2 - 85
WS-COUNT = 2
LENGTH = 2
Input-3 - 74OI
WS-COUNT = 2
LENGTH = 2
For the input-3 the WS-COUNT should come as 0 but I am getting 2 as a value.
Please find the console window screen shot below,
IN-VALUES :%ORIG243WE
COUNT :000
LENGTH :004
ADDRESSLINES: 43WE<br>
WS-SUB :004
IN-VALUES :%ORIG385
COUNT :002
LENGTH :002
ADDRESSLINES: 85<br>
WS-SUB :005
IN-VALUES :%ORIG474OI
COUNT :002
LENGTH :002
Could you anyone help me to resolve this.
You must initialize identifier-2 before execution of the INSPECT
statement begins.
So says the IBM Enterprise COBOL Language Reference, and the words will be similar in any COBOL manual.
identifier-2 is the target field of your TALLLYING.
If you do not set this to an initial value prior to the INSPECT, the current value will be used to add to (or not, in your case).
This is useful sometimes, but if you do not want to make use of it, you must set the identifier-2 field to zero before the INPSECT.
In your case that would be, for example (you could also use INITIALIZE, SET an 88 which has a zero in the first position of its VALUE clause, etc):
MOVE ZERO TO WS-COUNT
If you show your data-definitions, representative sample input and expected output, you may even get some hints about doing what it is that you want in a tidier way. If you tell us what it is you want.

Why is my if statement not determining the correct output in two nested performs?

I have this Cobol paragraph that will search one table which at this point in my example would have a table counter of 2 which is what the first INDEX loop does. The variable A represents an Occurs that is defined in a file (include) which has 5 occurrences. I can get to the if statement but it returns false. I read the information out of a ParmCard and store that in the table which is Table-B and the ParmCard is correct.
I did get it to find one value when was changing values around (conditional statements) but I know that both of the values that it is looking for in the ParmCard are in the file and should be found and it should find two results. I would have tried Expeditor but the system was down at work.
Is there something wrong with the index or may be I think that the perform's are working one way but they are really working a different way? This Search paragraph gets executed with every read of the ID file thus it will look in the table as many times as the ID file has an ID and ID symbols are unique.
Question: Why would the IF-STATEMENT not be working?
Code:
SEARCH-PARAGRAPH.
PERFORM VARYING SUB FROM 1 BY 1 UNTIL SUB > 2 <--DUPLICATE INDEXER
IF A(TAB) = TABLE-B(SUB) THEN
MOVE 6 TO TAB
MOVE 'TRUE' TO FOUND-IS
PERFORM WRITE-FILE THRU X-WF
PERFORM LOG-RESULT THRU X-LR
END-IF
END-PERFORM
X-SP. EXIT.
SEARCH-INDEX.
PERFORM VARYING I FROM 1 BY 1 UNTIL I > 2
DISPLAY 'INDEX --> ' I
PERFORM VARYING TAB FROM 1 BY 1 UNTIL TAB > 5
DISPLAY 'TAB --> ' TAB
PERFORM SEARCH-PARAGRPAH THRU X-SP
END-PERFORM
END-PERFORM.
X-SEARCH-INDEX. EXIT.
Here is the way that it works now and I do get the results I want. It is difficult to past the company code up because you never know who might have a problem.
New Code:
READ-PROV.
READ P-FILE
AT END
MOVE 'Y' TO EOF2
GO TO X-READ-PROV
NOT AT END
ADD 1 TO T-REC-READ
MOVE P-RECORD TO TEST-RECORD
PERFORM CHECK-MATCH THRU X-CHECK-MATCH
END-READ.
X-READ-PROV. EXIT.
CHECK-MATCH.
PERFORM VARYING SUB FROM 1 BY 1 UNTIL SUB > TABLECOUNTER
IF PID >= FROM(SUB) AND
PID <= THRU(SUB) THEN
IF TODAY < P-END-DTE THEN
IF TOTAL-PD = 0 AND
TOTAL-PD = 0 AND
TOTAL-PD = 0 AND
TOTAL-PD = 0 AND
TOTAL-PD = 0 THEN
IF PBILLIND NOT EQUAL 'Y'
PERFORM VARYING TAB FROM 1 BY 1 UNTIL TAB > 5
IF P-CD(TAB) = TY(SUB) THEN
MOVE 6 TO TAB
DISPLAY('***Found***')
ADD 1 TO T-REC-FOUND
END-IF
END-PERFORM
END-IF
END-IF
END-IF
END-IF
END-PERFORM.
X-CM. EXIT.
We can't tell.
There is nothing "wrong" with your nested PERFORM. The IF test is failing simply because it is never true.
We can't get you further with that without seeing your data-definitions, sample input and expected output.
However... my guess would be that the problem is with your data from the PARM in the JCL. That is the most likely area.
It is of course possible that the problem is with the other definition.
A couple of things whilst waiting.
Please always post the actual code, always. We don't want to look for errors in what you have typed here, we want to see the actual code. You have not shown the actual code, because it will not compile, as INDEX is a Reserved Word in COBOL, so you can't use it for a data-name.
Please always bear in mind that what you think may be wrong may not be the problem, so post everything we are likely to need (data-definitions, data you used, actual results you got with the code (including anything you've added for problem-determination), results which were expected).
Some tips.
A paragraph requires a full-stop/period after the paragraph-name and before the next paragraph. If you put that second full-stop/period on a line of its own, and have no full-stops/periods attached to your PROCEDURE code itself, you'll make things look neater and avoid problems when you want to copy some lines which happen to have a full-stop/period to a place where they cause you a mess.
You are using literal values. This is bad. When the number of entries in one of your tables changes, you have to change those literal values. Say the 2 needs to be changed to 5. You have to look at every occurrence of the literal 2 and decide if it needs to be changed. Then change it to 5. Then you get another request, to change the table which originally had five entries so that it will have six. See how difficult/error-prone life can be?
If instead you have unique and well-named data-names for your maximum number of entries, you only have one place to make a change, and you know it can be changed without reference to the rest of the code (assuming someone clever hasn't seen it has a value they want for something, and use it despite its name, of course...).
The content of those fields you can set automatically:
01 TABLE-1.
05 FILLER OCCURS 2 TIMES.
10 A PIC X(10).
01 TABLE-2.
05 FILLER OCCURS 5 TIMES.
10 TABLE-B PIC X(10).
01 TABLE-1-NO-OF-ENTRIES COMP PIC 9(4).
01 TABLE-2-NO-OF-ENTRIES COMP PIC 9(4).
...
PROCEDURE DIVISION.
...
COMPUTE TABLE-1-NO-OF-ENTRIES = LENGTH OF TABLE-1
/ LENGTH OF A
COMPUTE TABLE-2-NO-OF-ENTRIES = LENGTH OF TABLE-2
/ LENGTH OF TABLE-B
DISPLAY TABLE-1-NO-OF-ENTRIES
DISPLAY TABLE-2-NO-OF-ENTRIES
That gives you the output 2 and 5.
The names I've used are a mixture of yours and some for demonstration purposes only. Make everything meaningful, and by that I don't mean trite, as my example names would be in real life.
If you insist on escaping from within your PERFORM like that (and take note of Bruce Martin's comment), you can calculate your escape value by using new, aptly-named, fields and giving them the value of the above plus one.
To do a nested loop when the outer loop only has two entries is overkill. You don't need to escape out of the loops like you do, if you have a termination condition on the loop.
That'll do for now until we see your definitions, data and results.

Error in file.read() return above 2 GB on 64 bit python

I have several ~50 GB text files that I need to parse for specific contents. My files contents are organized in 4 line blocks. To perform this analysis I read in subsections of the file using file.read(chunk_size) and split into blocks of 4 then analyze them.
Because I run this script often, I've been optimizing and have tried varying the chunk size. I run 64 bit 2.7.1 python on OSX Lion on a computer with 16 GB RAM and I noticed that when I load chunks >= 2^31, instead of the expected text, I get large amounts of /x00 repeated. This continues as far as my testing has shown all the way to, and including 2^32, after which I once again get text. However, it seems that it's only returning as many characters as bytes have been added to the buffer above 4 GB.
My test code:
for i in range((2**31)-3, (2**31)+3)+range((2**32)-3, (2**32)+10):
with open('mybigtextfile.txt', 'rU') as inf:
print '%s\t%r'%(i, inf.read(i)[0:10])
My output:
2147483645 '#HWI-ST550'
2147483646 '#HWI-ST550'
2147483647 '#HWI-ST550'
2147483648 '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
2147483649 '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
2147483650 '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
4294967293 '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
4294967294 '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
4294967295 '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
4294967296 '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
4294967297 '#\x00\x00\x00\x00\x00\x00\x00\x00\x00'
4294967298 '#H\x00\x00\x00\x00\x00\x00\x00\x00'
4294967299 '#HW\x00\x00\x00\x00\x00\x00\x00'
4294967300 '#HWI\x00\x00\x00\x00\x00\x00'
4294967301 '#HWI-\x00\x00\x00\x00\x00'
4294967302 '#HWI-S\x00\x00\x00\x00'
4294967303 '#HWI-ST\x00\x00\x00'
4294967304 '#HWI-ST5\x00\x00'
4294967305 '#HWI-ST55\x00'
What exactly is going on?
Yes, this is the known issue according to the comment in cpython's source code. You can check it in Modules/_io/fileio.c. And the code add a workaround on Microsoft windows 64bit only.

Resources