I think two ppo bugs

95 views
Skip to first unread message

Quique

unread,
Nov 22, 2022, 1:01:38 AM11/22/22
to Harbour Developers
first a command that it not translate all command

#XCOMMAND WEB [DO] WHILE <fin> [<v:VAR,VARS> <params,...>] [<i:END DO,ENDDO,END> <id>([<params2,...>])] => ;
   if eval( <{fin}> ) ;;
      do while .t. ;;
         if memvar->qs_data_run:nNext == 2      ;;
         elseIf memvar->qs_data_run:nNext == 1  ;;
            if !memvar->qs_data_run:bucle( <{fin}> ) ;;
            endIf                               ;;
         else                                   ;;
            exit                                ;;
         endIf                                  ;;
      endDo                                     ;;
   else                                         ;;
   endIf

web DO WHILE lCont vars cAlias, lRet, lCont, nWait  end ocus(lRet, lCont, nWait)

result 

if eval( {|| lCont} ) ; while .T. ; if memvar->qs_data_run:nNext == 2 ; elseIf memvar->qs_data_run:nNext == 1 ; if !memvar->qs_data_run:bucle( {|| lCont} ) ; endif

It ends 

Second the #define and #undef doesn't work fine with #xcommand

#XCOMMAND miDefine <def> => #DEFINE <def>_aaa   "hola"
#XCOMMAND miUndef <def> => #UNDEF <def>_aaa

midefine x
? x_aaa

#DEFINE x_aaa  "hola"
? x_aaa

miUndef x
? x_aaa

result

QOut( x_aaa )


QOut( "hola" )

miUndef _aaa "hola"
QOut( "hola" )

I attach a prg with the same samples
prueba2.prg

Adam Lubszczyk

unread,
Nov 22, 2022, 8:30:34 AM11/22/22
to Harbour Developers
You have a very strange programming style.
Finding bugs must be a nightmare.  :)


#XCOMMAND WEB [DO] WHILE <fin> [<v:VAR,VARS> <params,...>] [<i:END DO,ENDDO,END> <id>([<params2,...>])] => ;
   if eval( <{fin}> ) ;;
      do while .t. ;;
         if memvar->qs_data_run:nNext == 2      ;;
         elseIf memvar->qs_data_run:nNext == 1  ;;
            if !memvar->qs_data_run:bucle( <{fin}> ) ;;
            endIf                               ;;
         else                                   ;;
            exit                                ;;
         endIf                                  ;;
      endDo                                     ;;
   else                                         ;;
   endIf

web DO WHILE lCont vars cAlias, lRet, lCont, nWait  end ocus(lRet, lCont, nWait)

result 

if eval( {|| lCont} ) ; while .T. ; if memvar->qs_data_run:nNext == 2 ; elseIf memvar->qs_data_run:nNext == 1 ; if !memvar->qs_data_run:bucle( {|| lCont} ) ; endif

Do not use  "endif" and "enddo" but simple  "end"
 

Second the #define and #undef doesn't work fine with #xcommand

#XCOMMAND miDefine <def> => #DEFINE <def>_aaa   "hola"

#xcommand  with  #define works a little differently:
   ... => #define   <def>_aaa   "hola"
work as
  ... =>  #define  <def>  _aaa  "hola"      (  <def> + space + _aaa )
so must use 2 steps like
  #xcommand  miDefine2  <def>   =>  #define  <def>  "hola"
  #xcommand  miDefine <def> =>  miDefine2  <def>_aaa

But undefine is very difficult - still  <def>_aaa is translated to "hola"  :(    After many tries I got the code:
------
PROCEDURE main

#xcommand __miDefine <xx> <def>  => ;;
 #xtranslate __miUndef <xx> => #undef <def> ;;
 #define <def> "hola" , <xx>

#xcommand miDefine <def> => __miDefine <def> <def>_aaa
#xcommand miUndef <def> => __miUndef <def>

? x_aaa
? y_aaa

? "Def X"
miDefine x
? x_aaa
? y_aaa

? "Def Y"
miDefine y
? x_aaa
? y_aaa

? "Undef X"
miUndef x
? x_aaa
? y_aaa


? "Undef Y"
miUndef y
? x_aaa
? y_aaa


RETURN
-------------------------
result in PPO:

PROCEDURE main

QOut( x_aaa )
QOut( y_aaa )

QOut( "Def X" )
;
QOut( "hola" , x )
QOut( y_aaa )

QOut( "Def Y" )
;
QOut( "hola" , x )
QOut( "hola" , y )

QOut( "Undef X" )

QOut( x_aaa )
QOut( "hola" , y )


QOut( "Undef Y" )

QOut( x_aaa )
QOut( y_aaa )

RETURN
----------


Adam

Quique

unread,
Nov 22, 2022, 11:21:50 AM11/22/22
to Harbour Developers
Thank you and I'm sorry.

The second error was my ignorance due to the correct functioning of #define, but the first one, although it has already been resolved thanks to your answer, I still think it is a bug for not accepting endIf and endDo.

Yes, it's some strange programming, but it's what I need to try to modify as little as possible sources that are already working correctly, and if the command works fine once, I don't have to worry about finding errors in the other places where it is. put, if anything, in the arguments used in the call ;-)

Just in case you were curious, it looked like this:

file.ch
#XTRANSLATE __defineIdBucle__ <id> <fin> => <id>_<fin>
#XCOMMAND __define__ <x> [<y,...>] => #define <x> <y>

#xcommand [<s:STAT,STATIC>] FUNCTION <name>([<params,...>]) => [<s>] func <name>(<params>) ;;
 #ifdef __WEB_FUNC__ ; #undef __WEB_FUNC__ ; #endif ;;
 #define __WEB_FUNC__ <name>_qsw

#XCOMMAND PAUSA WEB [ <llamada> ] RETURN => [ <llamada> ; ] memvar->qs_data_run:seguimientoWeb( {||{ {|x|x}, }}, "S" )

#XCOMMAND WEB FOR <var> := <ini> TO <fin> [STEP <step>] [<v:VAR,VARS> <params,...>] [<i:NEXT,END> <id>(<params2,...>)] => ;
   __define__ __defineIdBucle__ <id> FuNc  __defineIdBucle__ __WEB_FUNC__ next ;;
   __define__ __defineIdBucle__ <id> PaRaMs [<params2>]   ;;
   if eval( <{fin}> ) ;;
      memvar->qs_data_run:seguimientoWeb( {||{ @__WEB_FUNC__()[, <params>] }}, "B", <{fin}>, {||{ @<id>_FuNc()[, <params2>] }}, @<var>[, <{step}>] ) ;;
      do while .t. ;;
         pausa web __WEB_FUNC__( <params> ) return ;;

         if memvar->qs_data_run:nNext == 2      ;;
            memvar->qs_data_run:nNext := 0      ;;
            return <id>_FuNc( <params2> )       ;;

         elseIf memvar->qs_data_run:nNext == 1  ;;
            memvar->qs_data_run:nNext := 0      ;;
            if !memvar->qs_data_run:bucle( <{fin}>, @<var> [, <{step}> ] ) ;;
               return <id>_FuNc( <params2> )    ;;
            end                                 ;;
         else                                   ;;
            exit                                ;;
         end                                    ;;
      end                                       ;;
   else                                         ;;
      return <id>_FuNc( <params2> )             ;;
   end

#XCOMMAND WEB <e:END,END DO,ENDDO,NEXT> [<next>] ID <id> => ;
   return qs_data_run:nNext := 3 ; static function __defineIdBucle__ <id> FuNc( __defineIdBucle__ <id> PaRaMs ) ; #UNDEF <id>_FuNc ; #UNDEF <id>_PaRaMs

file.prg
      web DO WHILE lCont vars cAlias, lRet, lCont, nWait  end ocus(lRet, lCont, nWait)
? "ocus_FuNc", ocus_FuNc
? "ocus_PaRaMs", ocus_PaRaMs

      web ENDDO id ocus
? "ocus_FuNc", ocus_FuNc
? "ocus_PaRaMs", ocus_PaRaMs

file.ppo
 if eval( {|| lCont} ) ; memvar->qs_data_run:seguimientoWeb( {||{ @ocupado_qsw(), cAlias, lRet, lCont, nWait }}, "B", {|| lCont}, {||{ @ocupado_qsw_end(), lRet, lCont, nWait }} ) ; while .T. ; ocupado_qsw( cAlias, lRet, lCont, nWait ) ; memvar->qs_data_run:seguimientoWeb( {||{ {|x|x}, }}, "S" ) ; if memvar->qs_data_run:nNext == 2 ; memvar->qs_data_run:nNext := 0 ; return ocupado_qsw_end( lRet, lCont, nWait ) ; elseIf memvar->qs_data_run:nNext == 1 ; memvar->qs_data_run:nNext := 0 ; if !memvar->qs_data_run:bucle( {|| lCont} ) ; return ocupado_qsw_end( lRet, lCont, nWait ) ; end ; else ; exit ; end ; end ; else ; return ocupado_qsw_end( lRet, lCont, nWait ) ; end
WQout( { "ocus_FuNc", ocupado_qsw_end } )
WQout( { "ocus_PaRaMs", lRet, lCont, nWait } )

      return qs_data_run:nNext := 3 ; static func ocupado_qsw_end(lRet, lCont, nWait) ;
WQout( { "ocus_FuNc", ocus_FuNc } )
WQout( { "ocus_PaRaMs", ocus_PaRaMs } )

José M. C. Quintas

unread,
Nov 23, 2022, 2:07:56 AM11/23/22
to harbou...@googlegroups.com

Seems to me that the function will crash, because can enter in an infinite loop.

"Yes, it's some strange programming, but it's what I need to try to modify as little as possible sources that are already working correctly,"

Using things like this, you never will want to modify source code, because will be more difficult each day.

Why not to call a simple function, besides create a new function on each source code?


José M. C. Quintas

--
You received this message because you are subscribed to the Google Groups "Harbour Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to harbour-deve...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/harbour-devel/d5840795-7c40-4896-91af-cb9c96492b4dn%40googlegroups.com.

Bacco

unread,
Nov 23, 2022, 10:06:51 AM11/23/22
to harbou...@googlegroups.com
I believe since this is not a bug per se, further discussions
or sugestions on the code above and code style should
continue at the user's group


What do you think?

Regards
Bacco



Quique

unread,
Nov 23, 2022, 10:21:11 AM11/23/22
to Harbour Developers
Ok my next answer, if any, will be there, I think you're right, although it started with something I still believe is a bug.

Quique

unread,
Nov 23, 2022, 10:21:11 AM11/23/22
to Harbour Developers
I don't do a different function, because what we want is to try to keep the same code that we currently have, because we don't want to maintain two different programs for each modification, as long as it doesn't make money for the company to make it worthwhile, maybe time, and I think that's how it will be done (we'll have to discuss it with the boss), later we'll separate the code, and in fact, I think the best thing would be to change it to php, but for now it's about the same code that we have for a program made for windows, worked as a web server, and everything was fine, until we ran into the problem of windows inside loops. Those two commands that I put replace what would become the DO WHILE and ENDDO, in fact, I did modify it a bit, after that, because it didn't work correctly (it's not 100% tested yet, but the first simple test that urgent). The possibility of an infinite loop exists, but it is the same as in a DO WHILE .T., within the loop there is an if that has two RETURN possibilities and an EXIT, any of the 3 possibilities exit the loop, and this same code almost in its entirety will be the same one that is used for FOR/NEXT, I still have not considered FOR EACH, because luckily I have not needed it, but I think that this one will be more complex because I have no idea how to create the foreach objects, I'll see when the time comes, but I hope it's as simple as creating a child class used by the FOR EACH.

José M. C. Quintas

unread,
Nov 24, 2022, 1:24:55 AM11/24/22
to harbou...@googlegroups.com

May be anything like this?

#include "myfunction.ch"

----myfunction.ch----

STATIC TheFunction(....)

   DO WHILE .T.

      ...

   ENDDO


José M. C. Quintas

Reply all
Reply to author
Forward
0 new messages