just wondering is there is any advantage one way or the other between using
VAL=EXTRACT(RECORD,1,1,0)
vs.
VAL=RECORD<1,1>
------------------------------
Nelson Schroth
president
C3CompleteShop LLC
Harrison OH US
------------------------------
just wondering is there is any advantage one way or the other between using
VAL=EXTRACT(RECORD,1,1,0)
vs.
VAL=RECORD<1,1>
just wondering is there is any advantage one way or the other between using
VAL=EXTRACT(RECORD,1,1,0)
vs.
VAL=RECORD<1,1>
I MUCH prefer VAL = RECORD<1,1> over VAL = EXTRACT(RECORD<1,1,0)
It has fewer characters, and easier to find eg either FIND or SEARCH for CUSR<23 when looking for places where CUST file field 23 is read or written.
SEARCH over multiple files or FIND in UniDebugger to find where CUST file field 23 is read or written.
I MUCH prefer VAL = RECORD<1,1> over VAL = EXTRACT(RECORD<1,1,0)
It has fewer characters, and easier to find eg either FIND or SEARCH for CUSR<23 when looking for places where CUST file field 23 is read or written.
SEARCH over multiple files or FIND in UniDebugger to find where CUST file field 23 is read or written.
Each syntax will compile to the same object code so there should be no advantage in runtime performance to either syntax.
Each syntax will compile to the same object code so there should be no advantage in runtime performance to either syntax.
I think the EXTRACT function was originally the only way to extract values. The <x> syntax was added later although it was pretty early on. I've only seen the EXTRACT function used in old code. Kinda like user exits.
I think the EXTRACT function was originally the only way to extract values. The <x> syntax was added later although it was pretty early on. I've only seen the EXTRACT function used in old code. Kinda like user exits.
Joe,
Yes - I recall a time when EXTRACT() was the only way to do this. The <> notation came in some time in the esrly 80's I think - at least on Reality systems. I favour <> in modern code as it's shorter to code and simpler to read.
Regards
JJ
just wondering is there is any advantage one way or the other between using
VAL=EXTRACT(RECORD,1,1,0)
vs.
VAL=RECORD<1,1>
Demonstrating Neil's point that the 2 compile the same way, the universe VLIST command will let you see the compiled object, decompiled to a readable format.
DLIST command does something similar for I-descriptors.
See blue highlight below.:
>CT CDS.BP X
X
0001 VAL=EXTRACT(RECORD,1,1,0)
0002 VAL=RECORD<1,1>
>BASIC CDS.BP X
Compiling: Source = 'SOURCE/CDS.BP/X', Object = 'SOURCE/CDS.BP.O/X'
WARNING: Variable 'RECORD' never assigned a value. <-- (today, we dont care.)
Compilation Complete.
>VLIST CDS.BP X
Main Program "SOURCE/CDS.BP.O/X"
Compiler Version: 11.4.0.0
Object Level : 5
Machine Type : 11
Local Variables : 2
Subroutine args : 0
Unnamed Common : 0
Named Common Seg: 0
Object Size : 26
Source lines : 2
Object Date Time: 24 SEP 2024 09:19:16
00001: VAL=EXTRACT(RECORD,1,1,0)
00001 00000 : 060 dyn_extract RECORD 1 1 0 => VAL
00002: VAL=RECORD<1,1>
00002 0000C : 060 dyn_extract RECORD 1 1 0 => VAL
00002 00018 : 190 stop
>
-------------------------------------------------------------
something similar for I-descriptors:
DICT CDS.BP X
0001: I
0002: EXTRACT(@RECORD,1,1,0) ; @RECORD<1,1>
...
>DLIST CDS.BP X
Item 'X': EXTRACT(@RECORD,1,1,0) ; @RECORD<1,1>
Compiled 09:28 24 SEP 24
2 expressions
0 TOTALS
2 constants
0000: 060 dyn_extract @RECORD 1 1 0 => @1
000C: 060 dyn_extract @RECORD 1 1 0 => @2
0018: 0F8 move @2 => @ANS
001E: 15C return
>
Joe,
Yes - I recall a time when EXTRACT() was the only way to do this. The <> notation came in some time in the esrly 80's I think - at least on Reality systems. I favour <> in modern code as it's shorter to code and simpler to read.
Regards
JJ
I think that as soon as the REC<x,x,x> syntax was available EXTRACT and REPLACE became obsolete an only exist for backwards compatibility. Has anyone tried to replace the INSERT function by using negative indexes? Instead of:
RECORD = INSERT(RECORD, 1, 3;VALUE)
You could do this:
RECORD<1,-3> = VALUE
Having the negative index would insert before the number instead of replacing it.
Off hand it seems like it would work but I don't have time to thing through all the implications so I don't know.
I also think that once PERFORM and EXECUTE became available, Procs and paragraphs became obsolete. Why learn and maintain a separate language. I know that new developers really struggle with Procs and their input/output buffers and weird syntax. It's much easier to just do it in Basic.
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.