cgiorgio
1st February 2007, 20:27
Hy Guys...

I´m trying to do a function where i can write a basic script and run it from a session.....

Exemple:

function extern long teste_exec()
{
domain tcmcs.str80 buffer(500)
long expr_id
long aux
long num_linhas
num_linhas = text.to.buf("eucom206.scpt.o", language$, 500, buffer)
expr_id = expr.compile("buffer")
aux = l.expr(expr_id)
expr.free(expr_id)
return(0)
}

Where the buffer contents something like "If a=1 then message("ok") endif"... Only this....

the var "expr_id" return a compilation code... Like 2544121121... When the command "l.expr" runs this code, the B/W Message "Unknown symbol 'buffer' in expression:value 0 assumed"...

Somebody can help me????

Thanks so much...

evesely
1st February 2007, 20:48
Try getting rid of the quotes around buffer in the expr.complile. For example: expr_id = expr.compile(buffer)

Right now, it is trying to compile the literal expression "buffer" rather than the expression contained in the variable 'buffer'. Another point to make is that all variables in the compiled expression must be defined as extern.

I hope that helps.

_Ralph_
2nd February 2007, 12:49
I'd the same problem on this thread (http://www.baanboard.com/baanboard/showthread.php?t=30491)



num_linhas = text.to.buf("eucom206.scpt.o", language$, 500, buffer)
expr_id = expr.compile("buffer")
aux = l.expr(expr_id)
expr.free(expr_id)



Changing the variables to extern it do not return any error. But it continues without execute the script in "buffer"

any other suggestion??

reggards!

günther
2nd February 2007, 16:37
Although evesly said it very clearly, you did not exactly that. So here are my suggestions:

extern domain tcmcs.long a | otherwise you get a runtime error
extern domain tcmcs.long b

a = 1
b = 0

buffer = "if a = 1 then b = 2 endif" | just as a test w/o text.read

expr_id = expr.compile(buffer) | Note: no quotes!
if expr_id > 0 then
aux = expr.l(expr_id)
expr.free(expr_id)
endif

message("a=%d b=%d", a, b)


Günther

_Ralph_
2nd February 2007, 18:13
but the variable buffer is one array.
For every line on the script, there is one position on array.

expr.compile doesn't accept arrays.

regards

evesely
3rd February 2007, 16:21
Ah. I didn't see the array declaration the first time through.:o

You can always loop through the array and compile each line separately or concatenate things together and then compile. That would depend on what you expect to find in the text field. Of course, you would need to use a different extern variable name to hold the string you wanted to compile.

Hitesh Shah
8th February 2007, 19:24
AFAIK "if .. then..else...endif" is not supported in expr.compile . We have used operators ? (question mark) and : (colon) for that purpose . Multiple statements need to be separated by comma and variables used in dyanmic expression need to be declared extern . Expr.compile has limited support for many bshell functions ( as documented in help)

If u wish to use any Baan 4GL function u should use bic6.1 to compile them as functions in a dll .

SergioRuiz
19th November 2007, 09:34
Hi Hitesh , I´m trying to use the function domainof() with expr.compile but it doesn´t work, so how can i compile the function domainof in a dll to use it with expr.compile?

Thanks in advance.

Hitesh Shah
19th November 2007, 14:27
Earlier I had tried to use dll functions in a dynamic expression but without success . However then I used function parse_and_exec_function for my purpose. If at runtime the number of arguments dont change then exec_function / exec_dll_function can also help .

SergioRuiz
19th November 2007, 15:19
OK, I will try to use parse_and_exec_function, but one more question, do you know in wich standard Dll the domainof() function is?

Thank you so much!!

SergioRuiz
19th November 2007, 19:53
I´m not able to use parse_and_exec_function to use domainof() because I can´t find in which Dll is, I think the function is in one of the files in /baan/bse/include6.1 ,(bic_stdlib, bic_dll......) and I don´t know how to use parse_and_exec_function with this files.

Any suggestion? :o

Thanks in advance

Hitesh Shah
20th November 2007, 12:51
I think this dll can help . Else u can always use rdi functions (without dlls ) to get the domain of a table field .

SergioRuiz
20th November 2007, 13:41
Thanks, I will try it.
The trouble isn´t table fields, is the domain of variables. I didn´t want to put a field in my table to enter the domain of a variable if I could avoid it , but I start to realize that I have to manage this issue in that way.

Thank you so much for your help, ;)

Hitesh Shah
20th November 2007, 13:53
I dont know if u have tried $$ and $# 2nd argument of l.expr . Probably that may help .

Also ttdllextint has a function which gives all the form field variables along with related details in arrays. Probably that may be of some use .

SergioRuiz
20th November 2007, 13:57
I ´ve already tried $# but it crash at runtime.

Thanks.

Hitesh Shah
20th November 2007, 14:05
If u r in the field section of a field (for which u require domain) , u can probably use fattr.currfld$ and attr.domain$ pre-defined variables .

SergioRuiz
20th November 2007, 14:20
I have three fields of type string.

In one of these fields I put the name of other table fields or the name of variables, In the other 2 fields I can put the name of a dll and the function I want to execute(this is optional), so I need the domain at runtime to properly form the output string.

I have:
inxml003.field = "tppin100.ninv"
inxml003.cdll = "inxmldll0001"
inxml003.cfun = "inxmldll0001.get.data"

This could work with rdi.domain functions, but I want to be able to put variables in the inxml003.field

Thats my trouble.
I hope have explained better this time :D.

Hitesh Shah
22nd November 2007, 13:48
I have three fields of type string.

In one of these fields I put the name of other table fields or the name of variables, In the other 2 fields I can put the name of a dll and the function I want to execute(this is optional), so I need the domain at runtime to properly form the output string.

I have:
inxml003.field = "tppin100.ninv"
inxml003.cdll = "inxmldll0001"
inxml003.cfun = "inxmldll0001.get.data"

This could work with rdi.domain functions, but I want to be able to put variables in the inxml003.field

Thats my trouble.
I hope have explained better this time :D.

For report variables , u may need to read ttadv332 / 334 . For form fields u can get from a function in ttdllextint .

U may also consider to assign domains to the functions and generate functions accordingly and assign them to variables in your program at runtime .:)