Hi guys Im a researcher and not a great coder and I need help on something.
I have created a c++ program that converts a file called .nxs (nexus) to a file cslled a .med (mega) … This works in dos and is real simple..
I would like to add this to my webpage now.
Im thinking along the lines of creating a VERY scaled down version of this site .. hxxp://www.cbs.dtu.dk/services/TargetP/
For example , browse for file, hit submit… and BAM pingo
either a window comes up asking where you want to save this new file or a new http window popup with the new file in txt format for ctting and pasteing onto notepad.
btw both file formats are very simple txt notepad text files that have slightly different formats.. we just usually edit in notepad and save with new file extension…
this is my C below to give you an idea of what im doing..
thanx guys
brian
#include <iomanip.h>
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#define Max_Str_size 500
void main (int argc, char *argv[]) /
//void main()
{
system(“del tempin.nxs”);
system(“del tempout.nxs”);
if (argc > 3 ) {
FILE *streamIn;
FILE
char tempNameIn[] = “tempin.nxs”; //temp filename
char tempNameOut[] = “tempout.meg”; //temp filename
int x;
char temp[Max_Str_size];
char *fptr1; // pointer for ‘=’
char
char OutFileName[15];
char CommandStr[35];
//gotoxy(15,11);
//cout<< “Stand by try to read file “<< argv[1] << endl << endl;
strcpy(OutFileName, argv[1]);
fptr2 = strrchr(OutFileName, ‘.’); // find the last E in .EXE
OutFileName[fptr2 – OutFileName] = 0; // change it to null
strcat(OutFileName, “.meg”);
strcpy(CommandStr, “copy “);
strcat(CommandStr, argv[1]);
strcat(CommandStr, ” “);
strcat(CommandStr, tempNameIn);
//cout <<” CommandStr -> ” << CommandStr << endl;
system(CommandStr);
/*
cout <<” InFile Name -> ” << argv[1] << endl;
cout <<” OutFile Name -> ” << OutFileName << endl;
cout <<” Temp In File Name -> ” << tempNameIn << endl;
cout <<” Temp File Name -> ” << tempNameOut << endl;
clrscr();
gotoxy(15,11);
cout <<” Output File Name -> ” << OutFileName << endl;
if ((streamIn = fopen(tempNameIn, “r” )) == NULL) {
cout <<” File ” << tempNameIn << ” could not be opened”;
exit(1);
}
streamOut = fopen(tempNameOut, “w” ); // overwrite file
fprintf(streamOut,”#Megann”);
fprintf(streamOut,”!Title”);
for (x = 3; x < argc; x++) { // dump unwanted lines
fprintf(streamOut,” %s”, argv[x]);
}
fprintf(streamOut,”;n”); // end the command and line
fgets(temp, Max_Str_size, streamIn); // read in ditch the first line
fgets(temp, Max_Str_size, streamIn); // read in ditch the line
fgets(temp, Max_Str_size, streamIn); // read in
fptr1 = strchr(temp,’=’); // find char ‘=’
fptr1++; // move past ‘=’
//cout <<atoi(fptr1) << endl;
fptr2 = strchr(fptr1,’=’); // find char ‘=’
fptr2++; // move past ‘=’
fprintf(streamOut,”!Formatn”);
fprintf(streamOut,” DataType=%s DataFormat=Interleavedn”, argv[2]);
fprintf(streamOut,” NTaxa=%d NSites=%dn”, atoi(fptr1), atoi(fptr2));
fprintf(streamOut,” Identical=. Missing=? Indel=-n”);
fprintf(streamOut,” CodeTable=Standard;nnn”);
fprintf(streamOut,”!Domain=Data Property=Coding;n”);
for (x = 0; x < 6; x++) { // dump unwanted lines
fgets(temp, Max_Str_size, streamIn); // read in
//fputs(temp, streamOut); // write out
//cout <<temp;
}
while (temp[0] !=’;’) {
if (strlen(temp) > 2) fprintf(streamOut,”#%s”,temp);
else fprintf(streamOut,”%s”,temp);
fgets(temp, Max_Str_size, streamIn); // read in
}
fclose(streamIn);
fclose(streamOut);
// write a new suystem command
//strcat(OutFileName, “.meg”);
strcpy(CommandStr, “copy “);
strcat(CommandStr, tempNameOut);
strcat(CommandStr, ” “);
strcat(CommandStr, OutFileName);
//cout <<” CommandStr -> ” << CommandStr << endl;
system(CommandStr);
}
else {
clrscr();
system(“dir/b *.nxs”);
cout << “Syntax
}
}