A function that runs a command specified as a parameter

This forum is for eXpress++ general support.
Message
Author

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: A function that runs a command specified as a parameter

#12 Post by Eugene Lutsenko »

I tried to do this:

Code: Select all

MsgBox('INDEX ON PadRight('+aFieldName[ff]+','+aFieldSize[ff]+',".") TO Inp_tmp UNIQUE')
StartFunction('INDEX ON PadRight('+aFieldName[ff]+','+aFieldSize[ff]+',".") TO Inp_tmp UNIQUE')
Got this execution error when ADS is running:

Code: Select all

Function StartFunction(cText)
Local  bBlock := "{|| "+cText +"')}"
Local uResult
bBlock := &(bBlock)     // <<<===####### Error
uResult := eval(bBlock)
return uResult
Jimmy!
The key length limit of 25 did not work
Attachments
Безымянный.jpg
Безымянный.jpg (16.56 KiB) Viewed 4067 times
Безымянный.jpg
Безымянный.jpg (106.12 KiB) Viewed 4072 times

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

Re: A function that runs a command specified as a parameter

#13 Post by Auge_Ohr »

hi,

we talk about

Code: Select all

PadR()
which is a xBase Function but you use

Code: Select all

PadRight()
so change it and try again
greetings by OHR
Jimmy

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: A function that runs a command specified as a parameter

#14 Post by Eugene Lutsenko »

I'll try it now. And still there is a parameter in quotes: "."

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: A function that runs a command specified as a parameter

#15 Post by Eugene Lutsenko »

I tried it. The same error occurs. probably because of the quotes. Probably we should use the option with parameters

skiman
Posts: 1185
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: A function that runs a command specified as a parameter

#16 Post by skiman »

Hi,

You can't use command, you need to use functions!

Command are 'converted' to functions with the include files when compiling. Instead of 'index on' you need to use 'dbcreateindex()'.
Best regards,

Chris.
www.aboservice.be

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: A function that runs a command specified as a parameter

#17 Post by Eugene Lutsenko »

hi!

Code: Select all

StartFunctTXT('DbCreateIndex("Inp_tmp", PadR('+aFieldName[ff]+','+aFieldSize[ff]+',"."), .T. ')
Attachments
Безымянный.jpg
Безымянный.jpg (102.96 KiB) Viewed 4053 times

User avatar
Auge_Ohr
Posts: 1407
Joined: Wed Feb 24, 2010 3:44 pm

Re: A function that runs a command specified as a parameter

#18 Post by Auge_Ohr »

hi,

build a String, which is incorrect, before pass to Function
greetings by OHR
Jimmy

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: A function that runs a command specified as a parameter

#19 Post by Eugene Lutsenko »

hi!
Fixed

Code: Select all

                    MsgBox('DbCreateIndex("Inp_tmp", PadR('+aFieldName[ff]+','+aFieldSize[ff]+',"."), .T.)')
                    StartFunctTXT('DbCreateIndex("Inp_tmp", PadR('+aFieldName[ff]+','+aFieldSize[ff]+',"."), .T.)')

Code: Select all

******************************************************************************************
******** Функция, которая запускает команду, заданную в виде текстового параметра
******************************************************************************************
Function StartFunctTXT(cText)
Local  bBlock := "{|| "+cText +"')}"
Local uResult
bBlock := &(bBlock)     // <<<===####### Error
uResult := eval(bBlock)
return uResult
******************************************************************************************
Attachments
Безымянный.jpg
Безымянный.jpg (15.58 KiB) Viewed 4045 times
Безымянный2.jpg
Безымянный2.jpg (106.31 KiB) Viewed 4045 times

Post Reply