| Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 | 1. Array DLL #12993 Posted by: PeterJ 2009-06-06 20:55:03 Last edited by: PeterJ 2009-06-07 00:42:29 (Total edited 4 times) | I played with my large text file DLL, and extended it to allow processing of large arrays (>100,000 elements). In the attached zip file you find a brief description in Reginald Array DLL.pdf and some samples. Unzip the file and run ArrayNumeric. rex, ArrayString.rex. In comparison you can also run ArraySample.rex which operates which normal stem variables. | 2. #13002 | I've not been able to download this file, seems to be a forum size limitation, anyone else been able to download ? Doug | 3. I had no problems with it #13003 | | 4. #13004 Posted by: PeterJ 2009-06-15 23:53:21 | do you the "download verification" screen? this seems a new feature before downloading files. Sometimes it's containing strange encrypted characters. | 5. Got it now #13033 Posted by: Doug Arndt 2009-06-27 21:05:40 Last edited by: Doug Arndt 2009-06-27 21:06:07 (Total edited 1 time) | I don't recall getting that verification screen before, but I'm on a different computer right now, using Opera, latest version. This time it worked ok. Doug | 6. Starting to muck around with this code and having some problems #13059 Posted by: Michael S 2009-07-08 17:12:01 Last edited by: Michael S 2009-07-08 17:20:26 (Total edited 2 times) | I'm sure it's my fault, but the following code doesn't seem to work
rc = registerarray.rex()
IF rc <> 0 THEN
DO
SAY 'Return code 'rc' from registerarray.rex'
RETURN
END
sourcecode_token = globals('sourcecode',100000)
SAY 'sourcecode_Token = 'sourcecode_token
records=fetch(sourcecode_token,'GUIF2110.CBL')
recordsv=fetchv('sourcecode','GUIF2110.CBL')
SAY 'records = 'records', recordsv = 'recordsv
content=gets(sourcecode_token, 100)
SAY 'Content of record 100 = 'content
itemno=search(sourcecode_token,'IDENTIFICATION DIVISION.',1,50000,'M')
SAY 'Itemno = 'itemno
In the code above, I would also like to be able (to conform with existing code) to define the variable as a "normal" stem variable, ie, sourcecode. (note the trailing dot) - is this possible ?
Another point. Could you not introduce an option in SEARCH to IGNORE case (ie, obviously your code would have to "uppercase" all the items in the array before doing the search). I don't mean that the array items are ALL uppercased, only that you do an uppercase in your code internally before checking.
And another .... how do I "drop" a variable and restart. For example, suppose I'm processing the attached CBL file, but then I want to process another CBL file instead. Based on the documentation for FETCH(V), any new call to FETCH(V) will append the new CBL code to the existing stuff (which I don't want).
Documentation error ? In the PDF file, the SEARCH(V) call contains 5 arguments, but the example you have omits the value for end-number. Is this deliberate ? | 7. I include the error messages if they''ll help #13061 Posted by: Michael S 2009-07-08 17:30:07 Last edited by: Michael S 2009-07-08 17:31:11 (Total edited 1 time) | FETCHV gave FETCHV Message = RC: 8; MSG: 24450944 invalid Array token; TIMES: 24450944 invalid Array token/ The search "error". Just occurred to me - does search expect the search string to match the whole array item. For example, if an item in the array contains " IDENTIFICATION DIVISION. " (note thet blanks around the "string"), will SEARCH in the example above fail ??
That being the case, for my purposes, I need SEARCH to be able to find a string anywhere within an array item (I realise that performance will be degraded). The existing code I have does the equivalent of
.... POS(search_string,temp) ....
which obviously finds the string wherever it might be in the array item | 8. #13064 Posted by: PeterJ 2009-07-10 19:06:11 Last edited by: PeterJ 2009-07-10 19:13:56 (Total edited 4 times) |
recordsv=fetchv('sourcecode','GUIF2110.CBL')
you are right, it doesn't work in my environment either. I'll check it later.
itemno=search(sourcecode_token,'IDENTIFICATION DIVISION.',1,50000,'M')
the 'M' means line match, the string must exactly match with the array element. As the line contains additionally a line number at the end, there is no exact match use 'A' to check for substrings in elements, there is no real impact in performance.In the code above, I would also like to be able (to conform with existing code) to define the variable as a "normal" stem variable, ie, sourcecode. (note the trailing dot) - is this possible ? I am not sure that I understand your request. Defining an array like sourcecode_token = globals('sourcecode',100000) the arrayname 'sourcecode' is not a rexx variable nor a stem, it's indeed a simple string which identifies the array. It's stored in the arrays controlblock together with other array attributes. The contents of the array name is therefore not really limited as a rexx variable is. It could be
sourcecode_token = globals('123 My Array',100000)
or
sourcecode_token = globals('Looks.Like.STEM.',100000)
etc.
Another point. Could you not introduce an option in SEARCH to IGNORE case (ie, obviously your code would have to "uppercase" all the items in the array before doing the search). I don't mean that the array items are ALL uppercased, only that you do an uppercase in your code internally before checking. I had this already in place in an first version, but dropped it for reasons I can't remember. I will put it back again. And another .... how do I "drop" a variable and restart. In a newer version (not yet shipped) exists a DROPGLOBAL function. I'll prepare a new version over the weekend!
Peter | 9. Thanks Peter #13065 | Option 'A' - obviously didn't read the PDF properly.
recordsv=fetchv('sourcecode','GUIF2110.CBL')
Probably just because I'm so used to the LOADTEXT syntax, I would like to be able to define the array as
recordsv=fetchv('sourcecode.','GUIF2110.CBL')
which, from above, you're saying is no problem.
Look forward to the new version. | 10. #13067 Posted by: PeterJ 2009-07-13 14:33:52 | as promised here is the new version of the Array DLL. The documentation is updated!
@Michael: this a newer version than I send to you. SEARCH allows now a backward search, if array starting position is greater than end position!
These are the changes: SEARCH has an additional parameter to allow case sensitive/insensitive searches
Also new are:
GLOBALF/PUTF/PUTFV/ GETF/GETFV to support float variables
ERASEGLOBALx to erase parts or full array (but not the definition) DROPGLOBALx to remove the array including the definition COPYGLOBALx to copy an array partially to entirely into another array. | 11. Just did some testing on the new code #13068 Posted by: Michael S 2009-07-13 18:32:26 Last edited by: Michael S 2009-07-13 18:57:49 (Total edited 2 times) | and on the basis of the example I sent you (GUIF2110.CBL containing approx 3500 rows) the difference in elapsed time is noticeable.
Like I think I mentioned to you, I use reginald mainly for manipulation of COBOL source code. This means that I read the code in via LOADTEXT and then use STEMINSERT/STEMDELETE a lot. How do you see me applying that using your array code?
I can see inserting array items using a combination of GLOBALS, PUTSV and COPYGLOBALV, but what about if I need to delete items ?
From my personal, selfish point of view, I would appreciate the ability to do something similar to STEMINSERT/STEMDELETE with equivalent abilities. For example, if I have GUIF2110.CBL where ARRAYHIV returns 3500 items, then if I delete 100 itmes via your array processing, ARRAYHIV would now return 3400. Like I said, my personal selfish request for an improvement. | 12. Re:Just did some testing on the new code #13069 Posted by: PeterJ 2009-07-13 19:41:02 Last edited by: PeterJ 2009-07-13 19:42:44 (Total edited 1 time) | and on the basis of the example I sent you (GUIF2110.CBL containing approx 3500 rows) the difference in elapsed time is noticeable. Compared to what? STEMs, or my previous DLL?Like I think I mentioned to you, I use reginald mainly for manipulation of COBOL source code. This means that I read the code in via LOADTEXT and then use STEMINSERT/STEMDELETE a lot. How do you see me applying that using your array code?
I can see inserting array items using a combination of GLOBALS, PUTSV and COPYGLOBALV, but what about if I need to delete items ?
From my personal, selfish point of view, I would appreciate the ability to do something similar to STEMINSERT/STEMDELETE with equivalent abilities. For example, if I have GUIF2110.CBL where ARRAYHIV returns 3500 items, then if I delete 100 itmes via your array processing, ARRAYHIV would now return 3400. Like I said, my personal selfish request for an improvement. I am not sure that I understand your request. For deleting elements you have 2 ways: 1. PUTSx an empty string into the element you don't need. 2. ERASEGLOBALx to erase a range of elements What it doesn't do is changing (re-ordering) the element number. Is this what you want? Inserting elements: do you mean inserting elements into a certain position (and moving the current elements after the inserted elements.
Just let me know your "selfish" ideas, they don't look too difficult so far.
Peter | 13. Follow-on #13070 | Compared to .... stem variables. Here's an example of a (non) scientific comparison
rc = registerarray.rex()
IF rc <> 0 THEN
DO
SAY 'Return code 'rc' from registerarray.rex'
RETURN
END
globals('mySource.',100000)
start_time = TIME('S')
SAY 'Starting program'
filein = 'INLA9960.CBL'
recordsv=fetchv('mySource.',filein)
sw_finished = 0
arrayhi = arrayhiv('mysource.')
start_row = 1
DO WHILE sw_finished = 0
rc = searchv('mySource.','procedure division',start_row,arrayhi,,'N')
IF rc <> 0 THEN
DO
content=getsv('mySource.',rc)
IF SUBSTR(content,7,1) <> '*' THEN
sw_finished = 1
ELSE
start_row = rc + 1
END
END
end_time = TIME('S')
SAY 'Array time taken = 'end_time - start_time
start_time = TIME('S')
STREAM(filein, 'C', 'OPEN READ')
LOADTEXT('sourcecode.', filein)
STREAM(filein, 'C', 'CLOSE')
proc = find_procedure_division.rex(sourcecode.)
end_time = TIME('S')
SAY 'Old method - time taken = 'end_time - start_time
RETURN
Ooooops -must read the documentation better. PUTSV and ERASEGLOBALV are exacttly what I'm looking for. Is there a difference between the 2 ? What I mean by that is that the docs state that ERASEGLOBALV will reduce the value of ARRAYHIV - does PUTSV simply update the array item with an "empty" item, but without reducing ARRAYHIV (I don't have a problem with that - seems logical to me).
Reordering would be a "nice to have", but at the moment, I'm not sure if I actually need it. I don't see much of a problem writing, say, reginald scripts called ARRAYINSERTx and ARRAYDELETEx that do what I'm after.
I'll experiment with some code I have and let you know my results/remaining "selfish" requirements. | 14. Doug - your post # 5 #13071 | I noticed when I was trying to download the latest DLL Peter posted that I got the same request. It seems to be shown only if you haven't logged in. | 15. Am I misunderstanding what COPYGLOBAL should do ? #13072 | Run the following code
rc = registerarray.rex()
IF rc <> 0 THEN
DO
SAY 'Return code 'rc' from registerarray.rex'
RETURN
END
rc = logoption(1)
sourcecode_token = globals('sourcecode',100)
section_token = globals('section',10)
DO i = 1 TO 100
itemno=puts(sourcecode_token, i, 'This is sourcecode record 'i)
END
DO i = 1 TO 10
itemno=puts(section_token, i, 'This is section record 'i)
END
rc=copyglobal(section_token, sourcecode_token, 1, , 4)
SAY 'Rrecords copied = 'rc
hi=arrayhi(sourcecode_token)
SAY 'Value hi in sourcecode_token after copy = 'hi
DO i = 1 TO hi
content=gets(sourcecode_token,i)
SAY content
END
I was expecting the COPYGLOBAL to insert the rows from section between lines 4 and 5 in sourcecode. Ie, I was expecting sourcecode to have 110 items after the copyglobal. Is this doable (then we have the equivalent of STEMINSERT), either by default or using an extra parameter (that might possibly be better) | 16. Continuing on the last append #13076 | I created my own "version" of copyglobal as attached. I think there's a slight bug in the copyglobal array handling.
Run the attached scripts and look for the console string Temp records copied = xx I'm seeing the value 10 - shouldn't it be 3 instead ??? | 17. Have been testing Peter's array handling a bit #13095 | I have a program that searches for a specific string in scripts (similar to windows' search, but slightly different).
Searching 380 scripts of varying sizes, the standard LOADTEXT type of code takes 25 seconds. Peter's code runs through them in 9-10 seconds instead. Not bad at all !!!
I've written my code so that a global variable is set for Peter's array handling. That way I can easily switch it off if I should ever need to. Obviously you need to add code that tests for this variable and either works the old way or the new depending on which version is active. | Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next 1 |
|
|