A function that runs a command specified as a parameter
- Eugene Lutsenko
- Posts: 1649
- Joined: Sat Feb 04, 2012 2:23 am
- Location: Russia, Southern federal district, city of Krasnodar
- Contact:
A function that runs a command specified as a parameter
hi, all!
Is it possible to create a function that will execute a command specified as a parameter? It is possible to use a block of code in this function.
Is it possible to create a function that will execute a command specified as a parameter? It is possible to use a block of code in this function.
Re: A function that runs a command specified as a parameter
Hi,
I suppose this is what you want.
or
I suppose this is what you want.
Code: Select all
Function startfunction(cFunction,cPara1,cPara2)
Local bBlock := "{|| "+cFunction +"('"+cPara1+"','"+cPara2+"')}"
Local uResult
bBlock := &(bBlock)
uResult := eval(bBlock)
return uResult
Code: Select all
Function startfunction(cFunction,cPara1,cPara2)
Local bBlock := "{|cPara1,cPara2| " + cFunction+"(cPara1,cPara2) }"
Local bFunction
if IsFunction(cFunction)
bBlock := &(bBlock)
eval(bBlock,cPara1,cPara2)
else
msgbox("Function not available")
endif
return nil
- 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
hi, skiman !
Let's say I need to run an indexing command, but with a SPECIFIC field name specified directly by text, and not as a variable value and without using operators like FIELDGET, etc. How to do this using this function?
https://www.xbaseforum.de/viewtopic.php?f=42&t=12208
Let's say I need to run an indexing command, but with a SPECIFIC field name specified directly by text, and not as a variable value and without using operators like FIELDGET, etc. How to do this using this function?
https://www.xbaseforum.de/viewtopic.php?f=42&t=12208
Re: A function that runs a command specified as a parameter
hi,
you want to use a "UDF" in Index when using ADS ... hmEugene Lutsenko wrote: ↑Thu Feb 10, 2022 10:19 am https://www.xbaseforum.de/viewtopic.php?f=42&t=12208
greetings by OHR
Jimmy
Jimmy
Re: A function that runs a command specified as a parameter
Hi,
Something as this?
Something as this?
Code: Select all
Function createindex(cIndexFileName,cFieldnameAsText)
dbCreateIndex( (cIndexFileName), cFieldnameAsText)
return
Re: A function that runs a command specified as a parameter
hi Chris,
like under SQL you can not use a UDF with "own" Function using ADS as it is EVAL() "on-Server"
you must have a Db-Server like LetoDb or NetIO which are written in xBase (but not Xbaase++ )
in German Forum Eugene was told to reduce it
to work with ADS
like under SQL you can not use a UDF with "own" Function using ADS as it is EVAL() "on-Server"
you must have a Db-Server like LetoDb or NetIO which are written in xBase (but not Xbaase++ )
in German Forum Eugene was told to reduce it
Code: Select all
index on padr( feld, 25,"." )
greetings by OHR
Jimmy
Jimmy
Re: A function that runs a command specified as a parameter
There is no UDF in what Chris mentioned. Eugene looks for a way to create index files depending on the data situation, like: aIndexKeyFieldArray[n] contains the name of the field to be indexed. Since DbCreateIndex accepts textes as the index expression, this value can be used to create the index.
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: A function that runs a command specified as a parameter
hi Tom,
Eugene have point to this Thread https://www.xbaseforum.de/viewtopic.php?f=42&t=12208
where he want to use a Macro so i wrote
Eugene have point to this Thread https://www.xbaseforum.de/viewtopic.php?f=42&t=12208
where he want to use a Macro so i wrote
in German Forum Eugene was told to reduce it
greetings by OHR
Jimmy
Jimmy
- 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
hi!
What form of access to the DbCreateIndex() function is equivalent to the command: INDEX ON File_Date+File_Time TO StartAidos?
The DbCreateIndex() function is good. But I haven't had time to check how it works with ADS yet. I hope it's good. But I had another idea. I thought that if there was such a function that would execute the command given to it as a parameter, then there would be no questions at all. Moreover, she did not call an existing function, namely, she took it from the parameter and launched it. Like this:
ExecuteParameter("INDEX ON File_Date+File_Time TO StartAidos")
What form of access to the DbCreateIndex() function is equivalent to the command: INDEX ON File_Date+File_Time TO StartAidos?
The DbCreateIndex() function is good. But I haven't had time to check how it works with ADS yet. I hope it's good. But I had another idea. I thought that if there was such a function that would execute the command given to it as a parameter, then there would be no questions at all. Moreover, she did not call an existing function, namely, she took it from the parameter and launched it. Like this:
ExecuteParameter("INDEX ON File_Date+File_Time TO StartAidos")
Re: A function that runs a command specified as a parameter
Hi Eugene,
Which comes to the first sample.
So you can do startfunction( "dbCreateIndex( (cIndexFileName), cFieldnameAsText)")
Which comes to the first sample.
Code: Select all
Function startfunction(cText)
Local bBlock := "{|| "+cText +"')}"
Local uResult
bBlock := &(bBlock)
uResult := eval(bBlock)
return uResult