Below is some very rough code that demonstrates how to document each component in your project. I have found as my components multiply I wanted a way to have the data handy (mostly code imbedded in the component). Selwyn provided an undocumeted function that makes this possible.
Create a code file and run this. The only prompt that will appear is a ui box signaling the process completed. In a matter of seconds (depends on how many componets) it will create two text files, one detailing the name and type of component, the other with the actuual xbasic code. It could be combined in one file. It also creates a database table called comp_docs in your current project directory with the name of the component, the type and the xbasic code. I will develop my documentation in the form of a report.
As I said, it is rough. It could use more error checking and be incorporated in a nicely developed application format complete with user supplied input and prompts.
Much of the documented text is courtesy of Alpha
For now, it provides me usefull documentation for all of my components without having to open each one.
Steve
Create a code file and run this. The only prompt that will appear is a ui box signaling the process completed. In a matter of seconds (depends on how many componets) it will create two text files, one detailing the name and type of component, the other with the actuual xbasic code. It could be combined in one file. It also creates a database table called comp_docs in your current project directory with the name of the component, the type and the xbasic code. I will develop my documentation in the form of a report.
As I said, it is rough. It could use more error checking and be incorporated in a nicely developed application format complete with user supplied input and prompts.
Much of the documented text is courtesy of Alpha
For now, it provides me usefull documentation for all of my components without having to open each one.
Steve
Code:
'Date Created: 21-Feb-2007 01:30:39 PM 'Last Updated: 21-Feb-2007 03:55:20 PM 'Created By : 'Updated By : dim DBpath as c dim shortname as c dim longname as c dim tbl as P dim xbasic as c dim result as c Dim comp_name as c Dim comp_type as c shortname = "[default]\*.a5wcmp" 'the shortname has the projectname in [ ] longname = a5wcb_friendlyname_decode(shortname) 'the longname is the fully filename of the component file_list = filefind.get(longname, 0, "PN") 'this creates an array of all the components in your project 'this section creates text files detailing component info 'and a database file to display the component data 'test for the existence of text files, if exist, remove if file.exists("c:\docs.txt") = .t. then file.remove("c:\docs.txt") end if if file.exists("c:\file_names.txt") = .t. then file.remove("c:\file_names.txt") end if 'create table for comp data DBpath = a5.get_path() table.create_begin("comp_xbasic","m",60) table.field_add("comp_type","c",30) table.field_add("comp_name", "c", 30) tbl = table.create_end(Dbpath + "\\" + "comp_docs.dbf") 'The create_end() method creates the table and assign an object pointer to the table tbl = table.open("comp_docs.dbf") 'process the array and populate table and text files for each foo in file_list if foo <> "" xbasic = A5wcb_getGridInfo("xbasic",foo.value) 'the a5wcb_getGridInfo() function is for internal use and is therefore not documented. 'it is used to extract information from a saved component definition. even though the function name is a5wcb_getGridInfo() ' it can be used for other component types besides grids. 'the property that we want to extract is the 'xbasic' property. 'this is a string of xbasic code - the same code that you see in the Grid builder when you go to the Xbasic tab result = evaluate_template(xbasic) 'the xbasic code in this string creates a dot variable (called 'tmpl') and assigns properties to 'tmpl' 'we want to execute the code in this variable so that 'tmpl' is instantiated. 'to do this we use the evaluate_template() function. if there are any xbasic errors in the code 'that is execute, then 'result' will be non-null file.append("c:\docs.txt",xbasic) comp_type = tmpl.ComponentType ' set variables with different propoerties if comp_type="NavigationSystem" ' check for navigation comp name comp_name = tmpl.name else comp_name = tmpl.componentName ' dialog and grid use this property End if file.append("c:\file_names.txt",comp_name + " " + comp_type + crlf(1)) tbl.enter_begin(.T.) tbl.comp_name = comp_name tbl.Comp_Xbasic = xbasic tbl.comp_type = comp_type tbl.enter_end(.T.) end if next FILE_ADD_TO_DB(Dbpath + "\\" + "comp_docs.dbf") ui_msg_box("Done!","The process has been completed.") end
Comment