Add function 'remzerovec' to remove vectors of length 0

from current plot. Maybe of interest if you have option
savecurrents, write xx all, and ac generates length 0 vectors
This commit is contained in:
Holger Vogt 2020-05-02 20:06:58 +02:00
parent 3a00520071
commit 8a1eff8e88
3 changed files with 26 additions and 0 deletions

View File

@ -236,6 +236,10 @@ struct comm spcp_coms[] = {
{ 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS,
NULL,
"varname ... : Undefine vectors." } ,
{ "remzerovec", com_remzerovec, FALSE, FALSE,
{ 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS,
NULL,
"remove zero length vectors." } ,
{ "print", com_print, FALSE, TRUE,
{ 040000, 040000, 040000, 040000 }, E_BEGINNING, 1, LOTS,
arg_print,
@ -716,6 +720,10 @@ struct comm nutcp_coms[] = {
{ 040000, 040000, 040000, 040000 }, E_DEFHMASK, 1, LOTS,
NULL,
"varname ... : Undefine vectors." } ,
{ "remzerovec", com_remzerovec, FALSE, FALSE,
{ 040000, 040000, 040000, 040000 }, E_DEFHMASK, 0, LOTS,
NULL,
"remove zero length vectors." },
{ "print", com_print, FALSE, TRUE,
{ 040000, 040000, 040000, 040000 }, E_BEGINNING, 1, LOTS,
arg_print,

View File

@ -71,6 +71,23 @@ com_unlet(wordlist *wl)
} /* end of function com_unlet */
/* Remove zero length vectors in the wordlist from the current plot */
void
com_remzerovec(wordlist* wl)
{
NG_IGNORE(wl);
struct dvec* ov;
for (ov = plot_cur->pl_dvecs; ov; ov = ov->v_next) {
if (ov->v_length == 0) {
ov->v_flags &= ~VF_PERMANENT;
/* Remove from the keyword list. */
cp_remkword(CT_VECTOR, ov->v_name);
}
} /* end of loop over vectors to delete */
} /* end of function com_remzerovec */
/* Load in a file. */
void

View File

@ -15,6 +15,7 @@ void com_transpose(wordlist *wl);
void com_cross(wordlist *wl);
void com_destroy(wordlist *wl);
void com_splot(wordlist *wl);
void com_remzerovec(wordlist* wl);
void destroy_const_plot(void);