I'm using Visual Studio 2005 C++.
One of my cpp pages is named PKADEN.CPP. It contains a funtion named pkaden that calls a function named ev_num which returns a count back to pkaden. Ev_num is found in EVAL.CPP. This works fine, but I need to adjust these functions so ev_num passes a pointer to a linked_list back to PKADEN as well.
PKADEN - I'm not sure what I need to declare and how to pass it to ev_num.
ev_num - I get confused because there are global variables involved. Below is the code. I believe I want to pass *Saved back to PKADEN, but I'm not sure if this is right or if it is, how to do it:
EVAL.CPP:
One of my cpp pages is named PKADEN.CPP. It contains a funtion named pkaden that calls a function named ev_num which returns a count back to pkaden. Ev_num is found in EVAL.CPP. This works fine, but I need to adjust these functions so ev_num passes a pointer to a linked_list back to PKADEN as well.
PKADEN - I'm not sure what I need to declare and how to pass it to ev_num.
ev_num - I get confused because there are global variables involved. Below is the code. I believe I want to pass *Saved back to PKADEN, but I'm not sure if this is right or if it is, how to do it:
EVAL.CPP:
Code:
/* Defined types and constants */
static struct alist { /* Nodes of linked list: Paths */
int *p; /* Array of paths */
struct alist *Next; /* Next path */
};
/* Global variables */
static struct alist **Saved; /* Saved paths */
/*Ev_num calls a function that adjusts the struct alist. I'm able to write the information I need to a file from this funtion, but want to pass this back to PKADEN instead. Believe it has something to do with *Saved*/
int EV_Num(char *s, MOLECULE *m, RINGS *r)
{
int i;
int K_Frag, K_Chem;
if ( f == NULL ) {
if ( (f = InitMol()) == NULL ) {
return( -24 );
}
}
if ( (i = InSmi( s, f, &K_Frag, 1 )) != 0 )
return( 0 - i );
/* Make some initial checks to avoid path searches, if possible */
K_Frag = f->N_Bonds - f->N_Atoms;
K_Chem = m->N_Bonds - m->N_Atoms;
if ( f->N_Atoms > m->N_Atoms || f->N_Bonds > m->N_Bonds ) return( 0 );
if ( K_Frag > K_Chem ) return( 0 );
/* Fragment could exist, look for it */
N_Frag = 0;
StackNull();
Max_Level = SetSearchPath();
for ( i = 0; i < m->N_Atoms; i++ ) Visited[i] = FALSE;
/* Always try to avoid search if possible */
if ( (K_Chem = InitStartList( m, r )) == 0 ) return( 0 );
/* Too bad, must do search */
//allocate a new node
Saved = (struct alist **) malloc(sizeof(struct alist*));
*Saved = (struct alist *)NULL; /* Linked list of saved paths */
GetPath( m, r ); /* Get the paths */
/*New, added by JFN, pass the unique atom IDs for the fragment found. Below is what I want to do in PKADEN
struct alist *t;
ofstream myfile;
myfile.open ("c:\\pkatest\\Pattern.txt");
while ( *Saved != NULL ) {
t = *Saved;
myfile << "Got Here\n";
for ( i = 0; i < Max_Level; i++ ){
myfile << t->p[i];
}
*Saved = t->Next;
}
myfile.close();
RemoveAllStack();
DeletePath(); used to be here. However, need to use the paths for new PKA program yet,
so moving DeletePath()*/
return( N_Frag);
}