Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Compiler does not catch this syntax error, bug?
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00901990
Message ID:
00903250
Views:
17
Hi Frank, Hi David,

Good morning, it's morning here in California anyway.

Honoustly, what makes more sense to you.
>
>>>
>>>copy file ("a.txt") to ("c:\program files\my application\a.txt")
>>>
>>>
>
>or
>
>>
>>c = [copy file a.txt to "c:\program files\my application\a.txt"]
>>&c
>>


Honestly, they both equally make sense syntactically. Obiviously, I must admit, the former is more concise which I would choose to use in my code. Of course, I would never hard wire my code like the examples above.
The sample code really comes from a function that I created as follows:
FUNCTION CopyFile
	LPARAMETERS lpcFile1,lpcFile2,lpcSafety
	* lpcfile1 - source file
	* lpcfile2 - destination file 
	* [lpcsafety] - overwrite default on or off for set safety 
	LOCAL llReturn	
	IF PCOUNT()>=2 AND ;
		VARTYPE(m.lpcFile1)="C" AND ;
		NOT EMPTY(m.lpcFile1) AND ;
		FILE(m.lpcFile1) AND ;
		VARTYPE(m.lpcFile2)="C" ;
	THEN 
		LOCAL lcSafety
		m.lcSafety = SET("Safety") 
		IF VARTYPE(m.lpcSafety)=[C] AND ;
			NOT EMPTY(m.lpcSafety) AND ;
			INLIST(m.lpcSafety,'ON','OFF','on','off') ;
		THEN 
			SET SAFETY &lpcSafety
		ENDIF 
		LOCAL lcCmd 
		m.lcCmd = [copy file "] + m.lpcfile1 + [" to "] + m.lpcfile2 + [" ] 
		&lcCmd 
		m.llReturn = FILE(m.lpcFile2) 
		SET SAFETY &lcSafety
	ENDIF 
	RETURN m.llReturn 
ENDFUNC && CopyFile
So, from the above example, the lines:
LOCAL lcCmd 
m.lcCmd = [copy file "] + m.lpcfile1 + [" to "] + m.lpcfile2 + [" ] 
&lcCmd 
Can be reduced to:
copy file (m.lpcfile1) to (m.lpcfile2)
Yes, that is more concise. Thank you. I've learned alot since the begining of the thread.

"If you want my honest opinion, I think that you and your colleques need to understand why named expressions are better than Macro Substitution IF THEY CAN BE USED."

Yes, I respect a good, honest opnion. Honestly, I do not have a good grasp on this subject. Could you explain why named expressions are better than Macro Substitution, that is of course if you don't mind?

Sometimes a new version of VFP gives you a better way to solve a problem. You should embrace it instead of resist it.

I always embrace better ways of solving problems. Could you tell me what I am resisting?


Honestly,

Dawa
Dawa Tsering


"Do not let any unwholesome talk come out of your mouths,
but only what is helpful for building others up according to their needs,
that it may benefit those who listen."

- Ephesians 4:29-30 NIV

Dare to Question -- Care to Answer

Time is like water in a sponge, as long as you are willing you can always squeeze some.

--Lu Xun, Father of Modern Chinese Literature

Previous
Next
Reply
Map
View

Click here to load this message in the networking platform