Delete function

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
Nevillefc
Posts: 10
Joined: February 1st, 2013, 10:37 am
Location: CSO Trinidad and Tobago

Delete function

Post by Nevillefc »

I am attempting to use the "delete" function to remove records from a data file, however the statement isn't being compiled. The error I get says the "Record, group or multiple item name expected near ". I am certain that I am using the record name for the case in question. I haven't used the delcase function as that leaves the data in the file. This is the code I am using.

do varying i = totocc(survey_access_REC) until i <= 0 by (-1)
if Oper_folder = "DP01" and
oper_code = "201"
then
delete (survey_access_REC(i)); { remove operator's access to survey folder }
endif;
enddo;

where oper_folder and oper_code are id items. I get the error at the delete line in CSPro 4.1 . It passes the total occurances syntax, so the record seems to be valid.
htuser
Posts: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Delete function

Post by htuser »

How and were do you declare i? as numeric or as curocc(); ??
G.VOLNY, a CSProuser from Haiti, since 2004
Nevillefc
Posts: 10
Joined: February 1st, 2013, 10:37 am
Location: CSO Trinidad and Tobago

Re: Delete function

Post by Nevillefc »

i is a numeric and is declared in the proc global. I copied the code from the delete function in the cspro help.
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Delete function

Post by Gregory Martin »

The insert/delete functions are tricky. You don't use the record name but instead the "group" name, which you can find by looking at your form tree. It'll be similar to the record name, but with some numbers or letters added after it.

For example, if you are writing a batch application and want to delete SURVEY_ACCESS_REC(i), you would write:
delete(SURVEY_ACCESS_REC_EDT(i));
Or, in data entry it would look something like this:
delete(SURVEY_ACCESS_REC_FORM(i));
or:
delete(SURVEY_ACCESS_REC000(i));
Yana
Posts: 51
Joined: October 6th, 2016, 6:57 am

Re: Delete function

Post by Yana »

Dear Greg
If there is data that isn't necessary for the main data collection for example training data , and how to declare the delete function , is it from the Records or from the data files?
Thanks in advance
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Delete function

Post by Gregory Martin »

The delete function is for record occurrences. If you want to delete a case, you need to use the delcase function. However, you can't delete a case from the current file you're entering data into, so usually you use that function in a menu program.
Yana
Posts: 51
Joined: October 6th, 2016, 6:57 am

Re: Delete function

Post by Yana »

Dear Gregory
If there is any application based on deleting functions please post it .
Post Reply