hbnetio

Aqui você poderá oferecer suas Contribuições, Dicas e Tutoriais (Texto ou Vídeo) que sejam de interesse de todos.

Moderador: Moderadores

Ana Mitoooo
Usuário Nível 3
Usuário Nível 3
Mensagens: 118
Registrado em: 17 Out 2018 10:00
Localização: Sobradinho/DF

hbnetio

Mensagem por Ana Mitoooo »

Exemplo:

Código: Selecionar todos

   cFolder := '\Temp'
   IF ! hb_DirExists( cFolder )
      hb_DirCreate( cFolder )
   ENDIF
   
   IF ! hb_FileExists( cFolder + '\Teste.dbf' )
      dbCreate( cFolder + '\Teste', { { "COD", "N",  8, 0 }, { "DES", "C", 92, 0 } } ) 
   ENDIF
Como fazer o exemplo acima usando hbNetIo ?

Código: Selecionar todos

   // Pasta 'Temp' deve ser criada no path do hbNetIo (e não na raiz do disco em uso)
   ???
Avatar do usuário
Itamar M. Lins Jr.
Administrador
Administrador
Mensagens: 7928
Registrado em: 30 Mai 2007 11:31
Localização: Ilheus Bahia
Curtiu: 1 vez

hbnetio

Mensagem por Itamar M. Lins Jr. »

Olá!
Através das funções de usuário. Tem nos exemplos do NetIO. Olhem na pasta \contribs\hbnetio\tests
netio_FuncExec

Código: Selecionar todos


/* to execute this code run server (netiosrv) on the same machine
 * with support for RPC and "topsecret" password, i.e.:
 *    netiosrv "" "" "" 1 topsecret
 * then you can try to execute this code.
 * If you want to execute remotely any core functions then
 * uncomment this like in netiosrv.prg:
 *    REQUEST __HB_EXTERN__
 * and rebuild it or link netiosrv with Harbour dynamic library
 * (-shared hbmk2 switch)
 */


/* few PP rules which allow to execute RPC function using
 * pseudo object 'net', i.e. ? net:date()
 */
#xtranslate net:<!func!>( [<params,...>] ) => ;
            netio_FuncExec( #<func> [,<params>] )
#xtranslate net:[<server>]:<!func!>( [<params,...>] ) => ;
            netio_FuncExec( [ #<server> + ] ":" + #<func> [,<params>] )
#xtranslate net:[<server>]:<port>:<!func!>( [<params,...>] ) => ;
            netio_FuncExec( [ #<server> + ] ":" + #<port> + ":" + #<func> ;
                            [,<params>] )

#xtranslate net:exists:<!func!> => ;
            netio_ProcExists( #<func> )
#xtranslate net:exists:[<server>]:<!func!> => ;
            netio_ProcExists( [ #<server> + ] ":" + #<func> )
#xtranslate net:exists:[<server>]:<port>:<!func!> => ;
            netio_ProcExists( [ #<server> + ] ":" + #<port> + ":" + #<func> )


/* address of computer executing netiosrv,
 * change it if it's not the same machine
 */
#define NETSERVER  "127.0.0.1"
#define NETPORT    2941
#define NETPASSWD  "topsecret"


PROCEDURE Main()

   Set( _SET_DATEFORMAT, "yyyy-mm-dd" )

   /* connect to the server */
   ? "CONNECTING..."
   ? "netio_Connect():", netio_Connect( NETSERVER, NETPORT,, NETPASSWD )
   ?
   /* check if some function are available on server side */
   ? "Date() function is supported:",        net:exists:DATE
   ? "QOut() function is supported:",        net:exists:QOUT
   ? "hb_DateTime() function is supported:", net:exists:HB_DATETIME
   ?
   /* display text on server console */
   net:QOut( Replicate( "=", 70 ) )
   net:QOut( "This is RPC TEST", hb_DateTime(), Version() )
   net:QOut( Replicate( "=", 70 ) )

   /* execute some functions on the server side and display the results */
   ? "SERVER DATE:",     net:Date()
   ? "SERVER TIME:",     net:Time()
   ? "SERVER DATETIME:", net:hb_DateTime()
   ? net:Upper( "hello world !!!" )
   ?

   /* close the connection to the server */
   ? "netio_Disconnect():", netio_Disconnect( NETSERVER, NETPORT )

   RETURN
Saudações,
Itamar M. Lins Jr.
Saudações,
Itamar M. Lins Jr.
Responder