Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can I put multiple commands on a single line?
Message
De
17/09/1999 07:57:47
 
 
À
17/09/1999 00:20:35
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00264921
Message ID:
00265804
Vues:
23
Yeah, sure, everybody knows that you can create methods that have more than one line of code. Otherwise, why use methods?

The question here was: can you write more than one command on one line.

For example, is this legal:
lnI = 1 SELECT MyTable

The answer in no, VFP cannot execute more than one command by line. They have to be on separate lines.
>Hi Sylvain. I disagree with your point as I can use function to do so:
>
>For below Procedure, I can do For-loop, While-loop, Scan..EndScan by One Line Command!
>
>For instance,
>
>=FL(1,6,"? ix, Chr(64+ix)")
>
>Will print:
>
>1 A
>2 B
>3 C
>4 D
>5 E
>6 F
>
>If you modify the FL procedure by cuting down the cAction with Chr(13),
>You can handle more than ONE line command in For-loop!!
>
>but In the First Time I post this proc at UT, ppl said I can highlight the coding and
>right-click and select "Execute the highlight region" to do..
>That's means no need to make those proc!
>
>

>
>
>**	FOR LOOP
>PROCEDURE FL	&& make one line simple For-Loop
>LPARAMETERS nStart, nEnd, cAction, cExit, cLoop
>
>DO CASE
>CASE PCOUNT() = 3
>	FOR ix = nStart TO nEnd
>		&cAction
>	ENDFOR
>
>CASE PCOUNT() = 4
>	FOR ix = nStart TO nEnd
>		&cAction
>		IF (&cExit)
>			EXIT
>		ENDIF
>	ENDFOR
>
>CASE PCOUNT() = 5
>	IF !EMPTY(cExit)
>		FOR ix = nStart TO nEnd
>			&cAction
>			IF (&cExit)
>				EXIT
>			ENDIF
>			IF (&cLoop)
>				LOOP
>			ENDIF
>		ENDFOR
>	ELSE
>		FOR ix = nStart TO nEnd
>			&cAction
>			IF (&cLoop)
>				LOOP
>			ENDIF
>		ENDFOR
>	ENDIF
>ENDCASE
>ENDPROC
>
>** WHILE LOOP
>PROCEDURE WL	&& make one line simple While-Loop
>LPARAMETERS cCondition, cAction, cExit, cLoop
>
>DO CASE
>CASE PCOUNT() = 2
>	DO WHILE &cCondition
>		&cAction
>	ENDDO
>
>CASE PCOUNT() = 3
>	DO WHILE &cCondition
>		&cAction
>		IF (&cExit)
>			EXIT
>		ENDIF
>	ENDDO
>
>CASE PCOUNT() = 4
>	IF !EMPTY(cExit)
>		DO WHILE &cCondition
>			&cAction
>			IF (&cExit)
>				EXIT
>			ENDIF
>		ENDDO
>	ELSE
>		DO WHILE &cCondition
>			&cAction
>			IF (&cExit)
>				EXIT
>			ENDIF
>			IF (&cLoop)
>				LOOP
>			ENDIF
>		ENDDO
>	ENDIF
>	
>ENDCASE
>ENDPROC
>
>** SCAN FOR
>PROCEDURE SF	&& make one line SCAN.. ENDSCAN
>LPARAMETERS cFor, cAction, cExit
>
>DO CASE
>CASE PCOUNT() = 2
>	SCAN FOR &cFor
>		&cAction
>	ENDSCAN
>
>CASE PCOUNT() = 3
>	SCAN FOR &cFor
>		&cAction
>		IF (&cExit)
>			EXIT
>		ENDIF
>	ENDSCAN
>
>ENDCASE
>ENDPROC
>
>**	SCAN WHILE
>PROCEDURE SW	&& make one line SCAN.. ENDSCAN
>LPARAMETERS cWhile, cAction, cExit
>
>DO CASE
>CASE PCOUNT() = 2
>	SCAN WHILE &cWhile
>		&cAction
>	ENDSCAN
>
>CASE PCOUNT() = 3
>	SCAN WHILE &cWhile
>		&cAction
>		IF (&cExit)
>			EXIT
>		ENDIF
>	ENDSCAN
>
>ENDCASE
>ENDPROC
>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform