>Hello to all, How can write two o more instructions in one line of code, for example :
>
>* My program
>select('Mytable')
>Set order to ('MyIndex)
>Go top
>
>X=1
>Y=2
>Z=3
>
>* I want see this program in two line of code
>select('Mytable'), set order to ('MyIndex'), go top
>X=1, Y=2, Z=3
>
>This save papersheetand make less line of code...
>Is it possible ???
Hi Carlos,
As others have already noted, VFP has no built-in feature that allows you to combine multiple commands into a single line. It is possible, however, to create some simple generic UDFs that accomplish this. While I don't recommend using such an approach as a matter of general programming practice, there are a number of situations where I have found this to be very useful, e.g. for building menus and table-driven applications.
I've uploaded a few such handy UDFs to the directory at
http://www.ideaxchg.com/ix07/vm/_prg/. Briefly, these are summarized as follows:
DOCMD.PRG: executes a series of command lines, each passed as a character string argument.
IFCMD.PRG: a conditional form of DOCMD, where the first argument is a logical value which, if .T. causes the next argument (a command line) to be executed, otherwise all of the remaining command line arguments executed.
CMDPRG.PRG: a UDF that generates, compiles, runs, and cleans up a PRG obtained from an argument specifying one or more command lines (separated by newlines). It takes an optional output file name argument and returns an error code result. This relies on the runtime COMPILE command, which was introduced in VFP 6.0 SP3.
Further details are included in program comments.
Mike