Moderator: 2ffat
.ZER0 wrote:I need to create a program, which could open custom .h files and then use them afterwards. For now, i just tried #include "something.h" and it seems to work like i want.
ZER0 wrote:Can i just use opened .h file's path/file name for including it...
#include "A_Header_file.h"
// loaded from the current directory
#include <Another_file.hpp>
// loaded from the search path directories (set in Project Options)
// search starts in current directory, and then each of the search
// path directories in turn until file is found
ZER0 wrote:...or i need to recompile project after opening a file?
Whenever you change the contents of the #include list (by adding or removing file names, or changing any of their contents), you will need to recompile, so that the application is built with the new #include list. Unless you recompile, your applicatiion's .exe file will remain as it was before the changes.
Any changes you make in the Code Editor will not become effective until you have recompiled.
ZER0 wrote:I hope my situation is clearer now.
(A) Imagine I am a user sitting at your computer, with your application running. What do I do, and what does your application do in response?
(B) What is contained in your Data sets? Numeric values? Strings
(C) Where do your Data sets come from - how are they created?
ZER0 wrote:As a user, you browse and select function file which will be used for calculations. Then, program generates a matrix which is formed according to the outputs it gets when scrolling through all possible function inputs.
ZER0 wrote:Well, i have been provided with a set of theese .h files, i could include them all for now, by changing the function names,...
ZER0 wrote:...but the point is to make it possible to add more functions if needed in future.
ZER0 wrote:Hope we are getting somewhere,...
The project sounds like a fairly typical application.
Do you have any other files apart from the headers?
It would be useful to know whether the header files are normal BCB types, or whether there is something special about them.
void function(char *gg,char *og,int in,int on,int *ok)
{
int e10,e11,e16,e19;
// input 5, output 2
int ag[5],od[2],ii,m1=1;
*ok=1;
for(ii=0;ii<in;ii++)
if(*(gg+ii)=='0')
*(ag+ii)=0;
else
*(ag+ii)=1;
e10=m1-(*ag&*(ag+2));
e11=m1-(*(ag+2)&*(ag+3));
e16=m1-(e11&*(ag+1));
e19=m1-(e11&*(ag+4));
*od=m1-(e10&e16);
*(od+1)=m1-(e16&e19);
for(ii=0;ii<on;ii++)
if(*(od+ii)==0)
*(og+ii)='0';
else
*(og+ii)='1';
}Can you give us some idea of the level of your skills and experience in computing?
In your case at the moment, I am not all sure how to frame my responses so that they are useful to you, and do not create more problems than they solve.
make window
name = [newWindow]
caption = [New Window]
position 20, 20
width 100
height 200
end window
You could add all your existing functions into your application and present the user with a list of available functions to choose from. Everything that the program might want to use in the course of its execution will already be there and compiled in.
In the past I wrote an application that interpreted a script file which then produced the source code for a c# application, I believe that you are after something of a similar nature, not to produce source code but to return calculated values after reading in the parameters.
ZER0 wrote:I believe you're right. These files can be called script files, extension is not really important here i think. The point is to use the functions described. If you have any suggestions how to use these .h files like a script files, that would also solve my problem.
///ignore comments
///* db field value assigned to form control field ie text boxes
///<className> <dbFieldName> <frmControl>
///<className> = class creatd based on db Table Name and formatted _tablename
///<dbFieldName> database field
///<frmControl> aspx: TextBox other
///TO DO: scripted function names. ie function:{assign<className>FieldValues(_<className> <className>}
/// <function> public bool assign<className>FieldValues(_<className> <className>)
<bh classAssignFieldValues>
//---------------------------------------------------------------------------
public bool assign<className>FieldValues(_<className> <className>)
{
//-----------------------------------------------------------------
// page controls to tableClass members assignment
// <Class.ClassMember> = <Control.???>
// generated by CodeDjin " + <date>
//-----------------------------------------------------------------
<className>.success = true;
<do><className>.<dbFieldName> = (!=)frmControl)
<stop>
return(<className>.success);
}
<eh> //======================================================================
//---------------------------------------------------------------------------
void __fastcall TfrmMain::mnuClassMemberAssignmentClick(TObject *Sender)
{
if(!app._frmDb)
return;
int i, j;
AnsiString s;
TStringList* sl = new TStringList();
src->LoadFromFile(ExtractFilePath(Application->ExeName) + "stringGenerator.src.txt");
// generate code to assign textbox values to tableClass.members
if(!canContinue())
return;
if(frmDb->cbTables->Items->Count >0 )
{
if(frmDb->cbTables->ItemIndex != -1)
className = getClass(frmDb->cbTables->Items->Strings[frmDb->cbTables->ItemIndex]);
}
i=0;
while(src->Strings[i].Pos("classAssignFieldValues") !=0) //loop through until end of header <stop> //detected
i++; //increment until found
while(src->Strings[i].Pos("<stop>") ==0) //do until stop found
{
if(src->Strings[i].Pos("<date>") != 0)
src->Strings[i] = Replace(src->Strings[i],"<date>", "date");
if(src->Strings[i].Pos("<do>") != 0) //not end of function
process(src->Strings[i], sl ); //see function bellow...
if(src->Strings[i].Pos("<className>") != 0)
src->Strings[i] = Replace(src->Strings[i],"<className>", className);
if(src->Strings[i].Pos("<eh>") != 0) //not end of function
break;
if(src->Strings[i].Pos("<do>") == 0) //not end of function
{
if(src->Strings[i].Pos("///") == 0)
sl->Add(src->Strings[i]);
else
i++;
}
i++; //move to next src line
}
while(src->Strings[i].Pos("<eh>") == 0) //loop through until end of header <stop> //detected
{
if(src->Strings[i].Pos("<className>") != 0)
src->Strings[i] = Replace(src->Strings[i],"<className>", className);
if(src->Strings[i].Pos("<stop>") == 0)
sl->Add(src->Strings[i]);
if(i != src->Count)
i++;
}
activeFile = className + "_assign.aspx.cs";
// }
makeShowFields(sl);
resetClassValues(sl);
toArrayClass(sl);
createSession(sl);
//create notebook page
r[addNoteBookPage(className+ "_assign", ".aspx.cs")]->Text = sl->Text;
if(sl)
delete sl;
}
//---------------------------------------------------------------------------
AnsiString __fastcall TfrmMain::process(AnsiString s, TStringList *sl)
{
AnsiString a;// = line;
int pos, j;
pos = s.Pos("<do>"); //is it prototype instruction
arrayIndex = false;
if(s.Pos("<count>") !=0)
arrayIndex = true;
AnsiString token = "<className>";
if(pos != 0)
s = s.Delete(pos, 4);
for(j=1; j<frmDb->lbField->Items->Count; j++)
{
dbFieldType = frmDb->lbDataTypes->Items->Strings[j]; //database field type
dbFieldName = frmDb->lbField->Items->Strings[j] ; //database field name
frmControl = setFormControl(frmControls->lbTBOrder->Items->Strings[j]);
frmControlType = setFormControlType(frmControls->lbTBOrder->Items->Strings[j]);
// r_Property.dateListed = con.get(\"dbFieldName\")DateTime.Parse();"
pos = s.Pos("<className>");
if(pos !=0)
{
a = s; //will be - > <className>.dbFieldName = (!=)frmControl
a = ReplaceToken(a, token, className); //
a = ReplaceFieldName(a, dbFieldName);
pos = a.Pos("(!=)");
if( pos != 0)
{
a = iReplace(a, "(!=)");
a = stringReplaceType(a, frmControlType, dbFieldName);
}
else
a = stringReplaceType(a, frmControlType, dbFieldName);
//should end up like - > r_Property.dateListed = DateTime.Parse(teDate.Text);
// or like - > r_Property.dateListed = teDate.Text;
if(arrayIndex)
{
pos = a.Pos("<count>");
a.Delete(pos, 7);
a.Insert(IntToStr(j-1), pos);
}
sl->Add(a);
}
}
}
void function(char *gg,char *og,int in,int on,int *ok)ZER0 wrote:char gg is an input char of length in, and char og is an output char of length on.
As i've tried to use one included .h file, it seems to be working correctly, giving outputs for a certain input.
Users browsing this forum: No registered users and 4 guests