I was just doing a testing on index types.
Refer thread..
multiple idx or cdx files for different users?
thread1252-953855
In the process, I did not want my fields to have digits, though STR(number) produces an Alfa field, I wanted that to be alphanumeric. That means I have to convert the numbers into alpha. For example
1 = 'A'
2 = 'B'
..
26 = 'Z'
27 = 'AA'
..
52 = 'AZ'
53 = 'BA'
..
702 = 'ZZ'
703 = 'AAA' .... and so on
There is a similarity in the convertion. A little code should do the job.
A to Z is nothing but CHR(64+nNumber) where nNumber is 1 to 26
The same can be regressively called to build AA... etc.
But if the same where to be put in a PRG or as a function, calling itself will give an error. So we have to create a little custom class so that the object can be created within itself with ADDOBJECT until required. This is the concept I used to build that little tester. The class code is named 'AlfaRegression'.
Now to create a test cursor with 100,00 records, you can run the code..
Now where is this concept useful ?
We may want to create dummy records like this for testing and could be any numbe of records .. could million+ records.
OR
We may want to do similar regression in many places. Example 'resize class'. We have to resize each and every object inside a container object. We dont know how many PageFrame, Containers etc inside a form. In each of the Pageframe, there could be further Pageframes. I have forms in this manner. So we can use the syntax.. in a custom object..
FOR EACH oControl IN This.Controls
IF UPPER(oControl.BaseClass) $ 'PAGEFRAME#CONTAINER#whatever'
.. do whatever..
.. Add as an object in this object itself, when another PageFrame is found
ENDIF
ENDFOR
And there can be many other uses, once we understand that we can call the class from within itself and accept back a return value and cumulate that to be again returned to the calling method/procedure.
Good luck.
____________________________________________
ramani - (Subramanian.G)
Refer thread..
multiple idx or cdx files for different users?
thread1252-953855
In the process, I did not want my fields to have digits, though STR(number) produces an Alfa field, I wanted that to be alphanumeric. That means I have to convert the numbers into alpha. For example
1 = 'A'
2 = 'B'
..
26 = 'Z'
27 = 'AA'
..
52 = 'AZ'
53 = 'BA'
..
702 = 'ZZ'
703 = 'AAA' .... and so on
There is a similarity in the convertion. A little code should do the job.
A to Z is nothing but CHR(64+nNumber) where nNumber is 1 to 26
The same can be regressively called to build AA... etc.
But if the same where to be put in a PRG or as a function, calling itself will give an error. So we have to create a little custom class so that the object can be created within itself with ADDOBJECT until required. This is the concept I used to build that little tester. The class code is named 'AlfaRegression'.
Now to create a test cursor with 100,00 records, you can run the code..
Code:
*******************************************
SET TALK OFF
SET CONFIRM OFF
SET SAFETY OFF
CLEAR ALL
** Add 100,000 transactions and check
#define nCount 10000
** Create a dummy table
CREATE CURSOR dbfTest1 (nField1 I, cField2 C(20))
FOR i = 1 TO nCount
INSERT INTO dbfTest1 (nField1, cField2) ;
VALUES (i,'MySeed '+getAlfa(i))
ENDFOR
BROW
USE
RETURN
********************************************
FUNCTION getAlfa
LPARAMETERS tnInteger
LOCAL lcWord
oGetAlfa = NewObject('alfaRegression')
lcWord = oGetAlfa.getAlfa(tnInteger)
RELEASE oGetAlfa
RETURN lcWord
**************************************************
*-- Class: alfaregression (alfaregression.vcx)
*-- ParentClass: custom
*-- BaseClass: custom
*-- Time Stamp: 11/20/04 02:48:08 PM
*
DEFINE CLASS AlfaRegression AS custom
Name = "AlfaRegression"
*-- Convert integer to Alfa
PROCEDURE getAlfa
LPARAMETERS tnInteger
IF PCOUNT() < 1 OR ;
VARTYPE(tnInteger) # 'N' OR ;
tnInteger = 0
RETURN ''
ENDIF
LOCAL lcWord, lnNumber
lnNumber = MOD(tnInteger-1,26)+1
lcWord = CHR(64+lnNumber)
lnNumber = FLOOR((tnInteger - lnNumber)/26)
IF lnNumber > 0
This.AddObject('oGetAlfa', 'AlfaRegression')
lcWord = This.oGetAlfa.getAlfa(lnNumber) ;
+lcWord
This.RemoveObject('oGetAlfa')
ENDIF
RETURN lcWord
ENDPROC
ENDDEFINE
*
*-- EndDefine: AlfaRegression
**************************************************
Now where is this concept useful ?
We may want to create dummy records like this for testing and could be any numbe of records .. could million+ records.
OR
We may want to do similar regression in many places. Example 'resize class'. We have to resize each and every object inside a container object. We dont know how many PageFrame, Containers etc inside a form. In each of the Pageframe, there could be further Pageframes. I have forms in this manner. So we can use the syntax.. in a custom object..
FOR EACH oControl IN This.Controls
IF UPPER(oControl.BaseClass) $ 'PAGEFRAME#CONTAINER#whatever'
.. do whatever..
.. Add as an object in this object itself, when another PageFrame is found
ENDIF
ENDFOR
And there can be many other uses, once we understand that we can call the class from within itself and accept back a return value and cumulate that to be again returned to the calling method/procedure.
Good luck.
____________________________________________
ramani - (Subramanian.G)