Page 1 of 1

dc_interpret()

Posted: Mon Jan 16, 2012 2:22 am
by c-tec
Hello Roger,
how to use dc_interpet() correct ? It seems I am missing something in my code, for next loops are causing an error for example. Have I to call dc_translate() for using include files ? Do I have to define some standard include files like dcdialog.ch in my source ?
Best
Rudolf

Code: Select all

function itest()
local cSource := memoread("test.prg")
local aTmp := dc_progarray(cSource)
dcqdebug dc_interpret(aTmp)
return .t.

test.prg:

for x := 1 to 10
  dcqdebug x
next x



Re: dc_interpret()

Posted: Mon Jan 16, 2012 8:47 am
by c-tec
Hello Roger,
it seems that dc_translate() also does not work correct in my program, in your demo it translates my code correct.
regards
Rudolf

Code: Select all

function test()
******************************************************************
local cSource := memoread("test.prg")
cSource := conv2int(cSource)
dcqdebug dc_interpret(cSource)
*aTmp := dc_progarray(cSource)
*dcqdebug dc_interpret(aTmp)
return .t.

FUNCTION conv2int(cStatements)
******************************************************************
LOCAL nFunction, aTokens, j, cFunctions := '', aFunctions
altd()
aFunctions := DC_Translate(cStatements) 
FOR nFunction := 1 TO Len(aFunctions)
  aTokens := DC_TokenArray(aFunctions[nFunction], CRLF)
  FOR j := 1 TO Len(aTokens)
    IF !Empty(aTokens[j]) .AND. Left(aTokens[j],1) # '#'
      cFunctions += aTokens[j] + CRLF
    ENDIF
  NEXT j
NEXT nFunction
RETURN cFunctions


Re: dc_interpret()

Posted: Tue Jan 17, 2012 6:01 am
by c-tec
Hello,
also the translated code does not work, raise an error for line 3
regards
Rudolf

Code: Select all

FORNEXT x 1 10
DC_DotQOUT( {"test"} )
NEXT
DC_DotQOUT( {B_DOUBLE,B_SINGLE,HANDLE} )


Re: dc_interpret()

Posted: Tue Jan 17, 2012 9:22 am
by rdonnay
Rudolf -

The interpreter uses the macro compiler, so it can only do what the macro compiler can do.
You cannot create a function in interpreted code.

Roger