Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calling Beautify programatically
Message
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00660261
Message ID:
00663560
Views:
52
This message has been marked as the solution to the initial question of the thread.
Sergey,

Ok, I have it all working. I was sure I checked out the return file and it wasn't formatted. I don't know how I missed it. Anyway, here are the option settings:

Options:
1 = Variable case - 4 = no change, 3 = use 1st
2 = command Case - 3 = mixed, 1 = upper
3 = number of spaces if 4 = 2
4 = tabs/spaces, 2 - use spaces, 1 - use tabs
5 =
6 = comments - 1=include comments, 0 = no
7 = Line continuation 1 = include, 0 = no
8 = Extra indent beneath procedures 1 = yes, 0 = no
9 = Extra indent beneath Do Case 1 = yes, 0 = no

I usually use 3,3,4,1,0,1,1,0,0

Since those are actually binary values stored in a character string, you would need to make them act as if there were such a beast. So if you wanted to use my settings, you would use the following:

lcMyOptions = ;
Chr( 3) + Chr(0) +Chr(0) +Chr(0) +;
Chr( 3) + Chr(0) +Chr(0) +Chr(0) +;
Chr( 4) + Chr(0) +Chr(0) +Chr(0) +;
Chr( 1) + Chr(0) +Chr(0) +Chr(0) +;
Chr( 0) + Chr(0) +Chr(0) +Chr(0) +;
Chr( 1) + Chr(0) +Chr(0) +Chr(0) +;
Chr( 1) + Chr(0) +Chr(0) +Chr(0) +;
Chr( 0) + Chr(0) +Chr(0) +Chr(0) +;
Chr( 0) + Chr(0) +Chr(0) +Chr(0)

Now that I have all that working, I was able to finish my version of beautify which fixes a whole bunch of stuff with code (addes comment headers, formats code, fixes code incorrectly formatted by beautify, etc.)

Anyway, thanks again for your help.

Take care,

Fletcher

>After some experimenting, I got it working.
* Saved options from my beautify settings
>lcOptions = FILETOSTR("bt_opt.txt")
>Set Procedure to (HOME()+ "beautify.app")
>lcNewfile = Beautify( "bt_test.prg", lcOptions )
The lcNewfile variable holds the name of the temp file with formated code. If you get back file with unformated code than I would suspect that the options you're passing are incorrect. Just in case, I tested it under VFP7SP1.
>
>
>>Sergey,
>>
>>I simply ran the Beautify option from the tools menu. Blank out all the settings and run it with a breakpoint set. Then set the options and repeat. This helps you figure out what they mean, etc. But even if I use a "fake" set of options that I gleaned via this method, I still can't figure out where to go to get the nicely formatted code.
>>
>>Any ideas? No one in the world seems to know either....
>>
>>Thanks,
>>
>>Fletcher
>>
>>>Where did you find about the second parameter? What values does it accept?
>>>
>>>>Hi all,
>>>>
>>>>I want to call _Beautify programatically. I know I can do the following:
>>>>
>>>>do (_beautify) with "junk.txt", lcOptions
>>>>
>>>>where lcOptions is a binary character string of values. Unfortunately, while this seems to run fine, I can't find an output file with the formatted code.
>>>>
>>>>So I tried the following code (with junk.txt containing code to be formatted):
>>>>
>>>>Set Path to JustPath(_beautify)
>>>>Set Procedure to beautify.app
>>>>? beautify("junk.txt", zzz)
>>>>* returns a temp file name. But that is
>>>>* the source file, not formatted file....
>>>>aa = beautify("junk.txt", zzz)
>>>>? aa
>>>>
>>>>In further analysis, it appears that it does try to create an object OX based on the beautify class. Unfortunately, I can't get it to let me create that class. I have tried to set the library and procedure to the beautify.app, but to no avail.
>>>>
>>>>Any ideas on how to call _beautify such that you can get the formatted code? What about the options settings?
>>>>
>>>>Thanks,
>>>>
>>>>Fletcher
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform