The method which is delivered a variable 'i'.

The method which is delivered a variable 'i'.

Postby yunbg1 » Mon Mar 10, 2008 12:37 pm

hi Antonio

Make a Colsol Mode DLL program.
The method which is delivered a variable 'i'.

It is possible ?


--------------------------------
C++ consol mode test.DLL file --
--------------------------------

Code: Select all  Expand view

extern "C" __declspec(dllexport) int ar_init()
{
   int i;
   i=0;

   while(1) {

      i++;

   }
}



------------------------------------------------------------------------------
FWH + harbour_vc program --
------------------------------------------------------------------------------

Code: Select all  Expand view

#include "fivewin.ch"

//--------------------------------------------------------------------------------
FUNC main()

publ aSay, oSay, oTimer

aSay := 0

DEFINE WINDOW oWnd TITLE "Test"

    @ 10,  20 SAY oSay VAR aSay SIZE 150,22 PIXEL OF oWnd

ACTIVATE WINDOW oWndC MAXIMIZED ON INIT ( MMP_INIT(), timer() )

RETU NIL

//--------------------------------------------------------------------------------
FUNC timer()

DEFINE TIMER oTimer INTERVAL 10 ACTION oSay:Refresh()
ACTIVATE TIMER oTimer

RETU NIL

//--------------------------------------------------------------------------------
#pragma BEGINDUMP

#include "windows.h"
#include "hbapi.h"
#include "hbvm.h"

HB_FUNC( MMP_INIT )
{
   ar_init()
}
#pragma ENDDUMP



thank you.
FWH User
FWPPC User
FWLinux User
yunbg1
 
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada

Postby Antonio Linares » Mon Mar 10, 2008 3:10 pm

This portion of your code is an endless loop that will hang your application:
Code: Select all  Expand view
   while(1) {
      i++;
   }
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby yunbg1 » Tue Mar 11, 2008 3:39 pm

Hi Antonio Linares

Thank you

This application:

Code: Select all  Expand view
#include "fivewin.ch"

//--------------------------------------------------------------------------------
FUNC main()

publ g_Num, oSay, oTimer

g_Num := 0

DEFINE WINDOW oWnd TITLE "Test"

    @ 10,  20 SAY oSay VAR g_Num SIZE 150,22 PIXEL OF oWnd

ACTIVATE WINDOW oWndC MAXIMIZED ON INIT ( MMP_INIT(), timer() )

RETU NIL

//--------------------------------------------------------------------------------
FUNC timer()

DEFINE TIMER oTimer INTERVAL 5 ACTION oSay:Refresh()
ACTIVATE TIMER oTimer

RETU NIL

//--------------------------------------------------------------------------------
#pragma BEGINDUMP

#include "windows.h"
#include "hbapi.h"
#include "hbvm.h"

HB_FUNC( MMP_INIT )
{
   ar_init()
}
#pragma ENDDUMP



Code: Select all  Expand view
extern "C" __declspec(dllexport) int ar_init(){
{
  int stframe, endframe;
  stframe = (int)(floor(stpos*DEFAULT_RESAMPLING_RATE/FFTSTEP));
  endframe = (int)(ceil(endpos*DEFAULT_RESAMPLING_RATE/FFTSTEP));

  ifstream ifs_filelist(list.txt);

  int i=0, j=0;
  int g_Num = 0;     :shock: //--FWH RETURN---//
  int dim;
  char temp_buf[sizeof(int)*2];
  int feats_len=0, dbfeats_len=0;
  const char *filename_to_extract_feature=NULL;
  char *musicID_buf=NULL;
       
  int song_idx = 0;
  int song_feats_pos = 0, song_feats_num = 0;
  int feats_num = 0;
  ifs_filelist.seekg(0,ios::beg);
  const string suffix("mmp"); // extension of feature file

  while(1){
       
    string line;
    string path;
    string id;
    string::size_type idx;

    if (filename_to_extract_feature) filename_to_extract_feature =NULL;
               
    if(getline(ifs_filelist, line)==NULL)
    {
        path.erase();
        id.erase();
        line.erase();
        break;
    }
    stringstream line_stream(line);
    getline(line_stream, path, '\t');
    idx = path.find('.');
    path.replace(idx+1, string::npos, suffix);
    filename_to_extract_feature=path.c_str();

    getline(line_stream, id);
    musicID_buf=(char*)id.c_str();

    FEAT_TYPE* feats_buf = NULL;

    ifstream ifs_feats(filename_to_extract_feature, ios_base::binary);
    memset(temp_buf,0,sizeof(int)*2);
    ifs_feats.read(temp_buf, sizeof(int)*2);

    memcpy(&feats_len,temp_buf,sizeof(int));
    memcpy(&dim,temp_buf+sizeof(int),sizeof(int));
               
    if (feats_len < stframe)
    {
      return 1;
    }
    else
    {
      ifs_feats.seekg(stframe*dim*sizeof(FEAT_TYPE)+sizeof(int)*2, ios::beg);
      if (feats_len < endframe)
      {
        dbfeats_len = feats_len-stframe;
        feats_buf = new FEAT_TYPE[dbfeats_len*dim];
        if ( feats_buf == NULL ){
          return 1;
        }
        ifs_feats.read((char*)feats_buf, dbfeats_len*dim*sizeof(FEAT_TYPE));
      }
      else
      {
        dbfeats_len = endframe-stframe;
        feats_buf = new FEAT_TYPE[dbfeats_len*dim];
        if ( feats_buf == NULL ){
           return 1;
        }
        ifs_feats.read((char*)feats_buf, dbfeats_len*dim*sizeof(FEAT_TYPE));
      }
               
      if ( ifs_feats.is_open() ) ifs_feats.close();
      if (feats_buf) delete[] feats_buf;
      feats_buf = NULL;
                               
      song_feats_num = dbfeats_len;
      song_idx++;
      feats_num += song_feats_num;
    }

    if (filename_to_extract_feature) filename_to_extract_feature=NULL;
    if (musicID_buf) musicID_buf=NULL;
        path.erase();
        id.erase();
        line.erase();
    }

    g_Num ++;    :shock://Counter -Check hear---> FWH Return <------//

  }
  ifs_filelist.close();
  sg_num = song_idx;
  ft_num = feats_num;
  ft_dim = dim;
  return 0;
}


Long time read.............

Next file is "list.txt" file

Code: Select all  Expand view

D:\MMP_LIST\CCCH00020801.MMP SCHBERT1
D:\MMP_LIST\CCCH00020802.MMP SCHBERT2
D:\MMP_LIST\CCCH00020803.MMP SCHBERT3
D:\MMP_LIST\CCCH00020804.MMP SCHBERT4
                             .
                             .
                             .
                             .
                             .
                             .
                         100,000 list
                             .
                             .
                             .
D:\MMP_LIST\CCCH03220900.MMP SCHBERT1342345
D:\MMP_LIST\CCCH03220901.MMP SCHBERT1342346
FWH User
FWPPC User
FWLinux User
yunbg1
 
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada

Postby Antonio Linares » Tue Mar 11, 2008 5:12 pm

Is it working ?

If not, what error do you get ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby yunbg1 » Wed Mar 12, 2008 3:07 am

Sees the c++ source cord and it will be able to own jointly place this there is a g_Num variable from the FWH?
FWH User
FWPPC User
FWLinux User
yunbg1
 
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada

Postby Antonio Linares » Wed Mar 12, 2008 10:05 am

To assign the high level g_Num variable do this:

ACTIVATE WINDOW oWndC MAXIMIZED ON INIT ( g_Num := MMP_INIT(), timer() )

and add this in your C++ code, after final g_Num ++;
Code: Select all  Expand view
hb_retnl( g_Num );
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby yunbg1 » Thu Mar 13, 2008 2:14 am

Hi Antonio Linares

Thank you.

But.

'Process BAR' It makes from the (FWH + Habour OR FWH + xHabour).

If it is like that and 'MMP_INIT()' continuation after executing 'g_num'
the change comes over and process it will embody the bar to put out,

it isn't ?

Reply the execution is over now and completely
it comes out and 'g_num' the change to go over and it isn't to come ?
FWH User
FWPPC User
FWLinux User
yunbg1
 
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada

Postby Antonio Linares » Thu Mar 13, 2008 9:53 am

I don't understand what you mean, sorry.

Please show an example or explain it in a different way, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby yunbg1 » Fri Mar 14, 2008 4:30 am

Hi Antonio Linares

Thank you.

I will make 'Process bar' from (FWH + Harbour).

Then, I execute 'MMP_INIT()' and after that 'g_num' changes have to come over untill
I close the Program 'MMP_INIT()' that I can make 'Process bar'

This is (FWH + Harbour) code.

Code: Select all  Expand view
//--FWH + Harbour code --------------------------
//--FWH + Harbour code --------------------------
//--FWH + Harbour code --------------------------

#include "fivewin.ch"

//--------------------------------------------------------------------------------
FUNC Main()

publ oDlg, oProg, nValue := 0, oTimer, oMeter, line_count

oText := TTxtFile():New( "test.txt" )
         oText:GoBottom()
         line_count := oText:nLine
oText:End()

oMeter:nTotal := line_count

DEFINE DIALOG oDlg TITLE "TEST"

   @ 2,  2 METER oMeter VAR nValue TOTAL line_count OF oDlg SIZE 135, 12

   @ 3,  9 BUTTON "Exit" ACTION oDlg:End()

ACTIVATE DIALOG oDlg CENTER ;
         ON INIT ( timer(), mmp_start("test.txt") )

RETU NIL

//--------------------------------------------------------------------------------
FUNC timer()

DEFINE TIMER oTimer ACTION progress_bar()
ACTIVATE TIMER oTimer

RETU nil

//--------------------------------------------------------------------------------
FUNC progress_bar()

// Hear is point
// g_Num = C ++ DLL RETURN VALUE

nValue := g_Num  // ?????????????????????????????? How ?

oMeter:Set( nValue )

RETU NIL

/*--------------------------------------------------------------------------*/
#pragma BEGINDUMP

#include "windows.h"
#include "hbapi.h"
#include "hbvm.h"

HB_FUNC( MMP_START )
{
   mmp_init(hb_parc(1))
   hb_retni(0);
}

#pragma ENDDUMP
//--FWH + Harbour code  END--------------------------
//--FWH + Harbour code  END--------------------------
//--FWH + Harbour code  END--------------------------
//--FWH + Harbour code  END--------------------------


This is c ++ DLL code
'g_Num' Variable declaration method ????????
And the method which owns jointly the 'g_Num' with the FWH code.

Code: Select all  Expand view
/* C++ test.dll position source code------------- */
/* C++ test.dll position source code------------- */
/* C++ test.dll position source code------------- */
/* C++ test.dll position source code------------- */

extern "C" __declspec(dllexport) int mmp_init(char* file_list)
{

   ifstream ifs_filelist(file_list);

   while(1){

      string line;

      stringstream line_stream(line);
      getline(line_stream, id);

      g_Num ++
      //g_Num ++;  /*  (FWH + Hobour) code Change Return */

      if (g_Num > 200000) {
        break;
      }

     /*
      string line;
      string path;
      string id;
      string::size_type idx;

      if(getline(ifs_filelist, line)==NULL)
      {
        path.erase();
        id.erase();
        line.erase();
        break;
      }

      stringstream line_stream(line);

      getline(line_stream, id);

      getline(line_stream, path, '\t');
      idx = path.find('.');
      path.replace(idx+1, string::npos, suffix);
      filename_to_extract_feature=path.c_str();
      */
     
   }

   ifs_filelist.close();

   return 0;
}
/* C++ test.dll position source code end------------- */
/* C++ test.dll position source code end------------- */


This is test.txt sample code

Code: Select all  Expand view
/* test.txt sample code ABOUT : 200000 Line -------------------------------- */
/* test.txt sample code ABOUT : 200000 Line -------------------------------- */
/* test.txt sample code ABOUT : 200000 Line -------------------------------- */

\\C-net\c\000019\CCCH00001911.MMP EINE KLEINE NACHTMUSIK
\\C-net\c\000208\CCCH00020801.MMP SCHBERT;STRING QUINTET
\\C-net\c\000219\CCCH00021901.MMP BEETHOVEN:STRING QUARTETS
\\C-net\c\000287\CCCH00028706.MMP EXTRA TIME AMSTERDAM
............
............
............
............
............
\\C-net\c\000969\CCCO00096901.MMP PATRICK GALLOIS/POPULAR CLASSICS
\\C-net\c\000969\CCCO00096903.MMP PATRICK GALLOIS/POPULAR CLASSICS

/* test.txt sample code End-------------------------------- */
FWH User
FWPPC User
FWLinux User
yunbg1
 
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada

Postby Antonio Linares » Fri Mar 14, 2008 8:27 am

public g_Num

...

ACTIVATE DIALOG oDlg CENTER ;
ON INIT ( timer(), g_Num := mmp_start("test.txt") )

...

oMeter:Set( g_Num )

Or do you mean that you want to update the meter from the C++ function ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42080
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby yunbg1 » Sat Mar 15, 2008 2:05 pm

It calls a C++ DLL function from the FWH and it wants indicating a g_Num variable.

It wants embodying a 'Process BAR' from the FWH.
FWH User
FWPPC User
FWLinux User
yunbg1
 
Posts: 107
Joined: Sun Nov 13, 2005 12:40 am
Location: Winnipeg Canada


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 83 guests