Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
IsNumeric - VFP analogue?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00307922
Message ID:
00309445
Vues:
40
Hi George,
>>
>>>> You know, I was thinking about your idea to insert file description using macro. It's not very easy to implement, at least for me. But it would be great, if, say, we have description.txt file (may be few of them for different purposes) and have ability to add in the top (or current cursor position) of file (method of class/form) just pressing F7, for example.
>>>>
>>>>So, my suggestion to you (if, of course, it's not too much :), is to put such program with explanation in Files section.
>>>>
>>>>How does it sound?
>>>
>>>It isn't terribly hard to do. All you have to do is assign the _CLIPTEXT system variable the string you want to insert, then use the KEYBOARD command to paste in. Here's an example:
* Demopaste.prg
>>>#DEFINE CF_CR CHR(13)
>>>_CLIPTEXT = "This is line 1." + CF_CR
>>>_CLIPTEXT = _CLIPTEXT + "This is line 2." + CF_CR
>>>_CLIPTEXT = _CLIPTEXT + "This is line 3."
>>>KEYBOARD "{CTRL+V}" PLAIN
>>>* Initialize
>>>ON KEY LABEL F5 DO DEMOPASTE.PRG
That's all there is to it. When you press F5 you'll get
>>>
>>>This is line 1.
>>>This is line 2.
>>>This is line 3.
>>>
>>>Pasted into the current editing window. Of course, the above doesn't check to make sure that there's one active, but since this isn't an end-user tool, I don't worry about it< g >.
>>
>> It works great! Thanks, George.
>>
>> I've tried to modify this code a little, and, unfortunately, mine doesn't work.
>>1) I've created a test file Description.txt with few lines in it.
>>2) _CLIPTEXT=filetostr('Description.txt') - this doesn't work. Now _CLIPTEXT is only last string.
>>
>> What should I do?
>
>You'll probably have to bring the string into _CLIPTEXT one line at a time via the low level file functions. What's happening is that when you create a text file an additional character (CHR(10)) is added at the end of each line. So your file actually reads something like: "Line 1." + CHR(13) + CHR(10). Look at FOPEN(), FGETS() and FCLOSE(). What you'll have to do, is bring the string in line by line (that's why FGETS() rather than FREAD()) and concatenate the string yourself.

Thank you, George. I'll do it this way. It was while ago, when I last time used low level functions, but at least I had some experience with them in a past.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform