Hi there,
I am new to Accuterm, I am trying to create a CRED app using Accuterm and Unidata, I have successfully created a table of data using Unidata db, and now I am creating a delete action, but I have a lot of doubts about it, someone please explain how to create the code for the delete action.
Here it's the sample code for the delete action
READ RG.REC FROM RG.FILE,DID ELSE ER.REC = ''
AID = DATE():TIME():'R':DID
AID.REC = ''
AID.REC<1> = 'CODE'
READ VC.REC FROM VC.FILE,'CODE' ELSE VC.REC = ''
AID.REC<2> = VC.REC<2>
AID.REC<3> = 'DELETE'
AID.REC<6> =RG.REC
EXECUTE 'DELETE CODE ':DID
CALL ATGUIMSGBOX(DID:' Deleted','WARNING',2,0,0,RSP,GUIERRORS,GUISTATE)
WRITE AID.REC ON AD.FILE,AID
But, I don't understand how the code was works
kindly explain to me,
thank you
------------------------------
mohamed Azarudeen
Rocket Forum Shared Account
------------------------------
Hi Mohamed,
What specifically are you needing help with? Dynamic arrays, concatenation or how to delete a record from a file?
The " EXECUTE 'DELETE CODE ':DID" will delete the record from the CODE file with an id equal to whatever DID is set to. If your program has the code file opened you can do it more efficiently like this:
OPEN 'CODE' TO CODE.FILE ELSE STOP 201,'CODE'
...
DELETE CODE.FILE,DID
------------------------------
Joe Goldthwaite
Consultant
Phoenix AZ US
------------------------------
Hi there,
I am new to Accuterm, I am trying to create a CRED app using Accuterm and Unidata, I have successfully created a table of data using Unidata db, and now I am creating a delete action, but I have a lot of doubts about it, someone please explain how to create the code for the delete action.
Here it's the sample code for the delete action
READ RG.REC FROM RG.FILE,DID ELSE ER.REC = ''
AID = DATE():TIME():'R':DID
AID.REC = ''
AID.REC<1> = 'CODE'
READ VC.REC FROM VC.FILE,'CODE' ELSE VC.REC = ''
AID.REC<2> = VC.REC<2>
AID.REC<3> = 'DELETE'
AID.REC<6> =RG.REC
EXECUTE 'DELETE CODE ':DID
CALL ATGUIMSGBOX(DID:' Deleted','WARNING',2,0,0,RSP,GUIERRORS,GUISTATE)
WRITE AID.REC ON AD.FILE,AID
But, I don't understand how the code was works
kindly explain to me,
thank you
------------------------------
mohamed Azarudeen
Rocket Forum Shared Account
------------------------------
Hi Mohamed,
This isn't an AccuTerm question - this is a UniData question. I find your code quite odd - so let's go through it.
READ RG.REG FROM RG.FILE,DID ELSE ER.REC = ''
The first part of that is OK - but what is ER.REC ? It isn't used anywhere else here. It would make more sense here to have:
READ RG.REC FROM RG.FILE,DID ELSE RG.REC = ''
AID = DATE():TIME():'R':DID
OK. You are building an ID. Date will be a 5-digit number; Time will be 1 to 5 digits and depending on your options may have a decimal point and 3 decimal places. The you have an 'R' and whatever the DID variable is set to.
A common thing to do is to pull these ID's apart at a later date, and this structure makes it hard to do that. (OK, left of the 'R' is the date time, and we can assume that the date is 5-digits, so the rest is the time - but that is difficult). A common approach here is to use a delimited ID like this:
AID = DATE() : '*' : TIME() '0' : '*' : DID
Note that I have forced the TIME() to be an integer value here. If you want the decimal precision, then maybe use: ICONV(TIME((), 'MR3') for that section.
I haven't put the 'R' in there because it seems like a constant (but maybe you use something else elsewhere). Now, you can extract each of the fields quite simply:
adate = FIELD(AID, '*', 1)
atime = FIELD(AID, '*', 2)
adid = FIELD(AID, '*', 3)
Next, you build AID.REC. What is strange here is the line:
AID.REC<6> = RG.REC
Now, if RG.REC is really a record consisting of multiple attributes, then AID.REC is going to end up with 5 attribute plus the number of attributes in RG.REC. If you really want to put the whole of RG.REC into AID.REC<6> then you should have:
AID.REC<6> = LOWER(RG.REC)
Alternatively, if RG.REC is only a single attribute, then I would enforce the loading of a single attribute (because you will almost certainly end up with some case where RG.REC has multiple attributes)
AID.REC<6> = RG.REC<1>
The delete is straightforward: DELETE filename item-id But as was noted elsewhere, it is usual to OPEN the file, and then use DELETE file-pointer, id
HTH,
Brian
------------------------------
Brian Speirs
Senior Analyst - Information Systems
Rush Flat Ltd
Wellington NZ
------------------------------
Hi Mohamed,
This isn't an AccuTerm question - this is a UniData question. I find your code quite odd - so let's go through it.
READ RG.REG FROM RG.FILE,DID ELSE ER.REC = ''
The first part of that is OK - but what is ER.REC ? It isn't used anywhere else here. It would make more sense here to have:
READ RG.REC FROM RG.FILE,DID ELSE RG.REC = ''
AID = DATE():TIME():'R':DID
OK. You are building an ID. Date will be a 5-digit number; Time will be 1 to 5 digits and depending on your options may have a decimal point and 3 decimal places. The you have an 'R' and whatever the DID variable is set to.
A common thing to do is to pull these ID's apart at a later date, and this structure makes it hard to do that. (OK, left of the 'R' is the date time, and we can assume that the date is 5-digits, so the rest is the time - but that is difficult). A common approach here is to use a delimited ID like this:
AID = DATE() : '*' : TIME() '0' : '*' : DID
Note that I have forced the TIME() to be an integer value here. If you want the decimal precision, then maybe use: ICONV(TIME((), 'MR3') for that section.
I haven't put the 'R' in there because it seems like a constant (but maybe you use something else elsewhere). Now, you can extract each of the fields quite simply:
adate = FIELD(AID, '*', 1)
atime = FIELD(AID, '*', 2)
adid = FIELD(AID, '*', 3)
Next, you build AID.REC. What is strange here is the line:
AID.REC<6> = RG.REC
Now, if RG.REC is really a record consisting of multiple attributes, then AID.REC is going to end up with 5 attribute plus the number of attributes in RG.REC. If you really want to put the whole of RG.REC into AID.REC<6> then you should have:
AID.REC<6> = LOWER(RG.REC)
Alternatively, if RG.REC is only a single attribute, then I would enforce the loading of a single attribute (because you will almost certainly end up with some case where RG.REC has multiple attributes)
AID.REC<6> = RG.REC<1>
The delete is straightforward: DELETE filename item-id But as was noted elsewhere, it is usual to OPEN the file, and then use DELETE file-pointer, id
HTH,
Brian
------------------------------
Brian Speirs
Senior Analyst - Information Systems
Rush Flat Ltd
Wellington NZ
------------------------------
Thanks for your help! Now I was able to work with this code. I really appreciate it!"
------------------------------
mohamed Azarudeen
Rocket Forum Shared Account
------------------------------
Hi Mohamed,
What specifically are you needing help with? Dynamic arrays, concatenation or how to delete a record from a file?
The " EXECUTE 'DELETE CODE ':DID" will delete the record from the CODE file with an id equal to whatever DID is set to. If your program has the code file opened you can do it more efficiently like this:
OPEN 'CODE' TO CODE.FILE ELSE STOP 201,'CODE'
...
DELETE CODE.FILE,DID
------------------------------
Joe Goldthwaite
Consultant
Phoenix AZ US
------------------------------
Thanks for your help! Your advice for the delete action is worked. I appreciate it!"
------------------------------
mohamed Azarudeen
Rocket Forum Shared Account
------------------------------