Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Add new fileds
Message
De
01/11/2009 01:41:16
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Network:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01432174
Message ID:
01432551
Vues:
105
thank you for reply ,
this code take all department as one unit and calculate ...etc&& it is ok

i need to let the code take every department via deptno as one unit , via command button autamiticly,
as 
LOCAL lcSequenceString
lcSequenceString = '1,2,3,4,5,6,7,8,9,10,13,16,17,19,20,40,41,42,43,44,54,55,56,57,58,59,60,61,62,63,64,66,67,68,69,89,90,99'

if deptno=1 found()
 run the code 
else
 get deptno2 then deptno3 ....to depno99

endif

>What seems to be problem?
>
>>
>>this code below count and get exellent results for all data at the table , know i need to add new steps
>> at this code
>>
>>
>>i need to insert 1 fields deptno and deptname when i run the code below to print it at my report as every department aloan
>>
>>
>>*i  need help to insert the 2 lins below and print it all one by one autamticly.
>>*LOCAL lcSequenceString
>>*lcSequenceString = '1,2,3,4,5,6,7,8,9,10,13,16,17,19,20,40,41,42,43,44,54,55,56,57,58,59,60,61,62,63,64,66,67,68,69,89,90,99'
>>*this is the numbers of department
>>
>>this is the code at the form at command button and this method below
>>
>>
>>CLOSE all
>>
>>Use (thisform.text41.value) Exclusive
>>
>>gnFieldcount = AFIELDS(gaMyArray)
>>For nCount = 1 To gnFieldcount 
>> 
>>  If left(Upper(gaMyArray(nCount,1)),1)='Q' and gaMyArray(nCount,2)='C'&& begin with q and ather charcters
>>
>>    Wait "Converting "+gaMyArray(nCount,1) WINDOW nowait 
>>    Alter table (thisform.text41.value) alter column (gaMyArray(nCount,1)) n(10,2)
>>  EndIf 
>>EndFor 
>>Wait clear
>>
>>************************************
>>CLOSE all
>>#Define ANSWERCOUNT 20
>>#Define QUESTIONCOUNT 3
>>Local array aStruc[(ANSWERCOUNT+1)*2,4]
>>Local ix,lnPair
>>aStruc = 0
>>aStruc[1,1] = 'Question'
>>aStruc[1,2] = 'C'
>>aStruc[1,3] = 5
>>
>>For lnPair=1 To ANSWERCOUNT
>>      aStruc[m.lnPair*2,1] = 'CountOf'+Ltrim(Str(m.lnPair))
>>      aStruc[m.lnPair*2,2] = 'I'
>>      aStruc[m.lnPair*2,3] = 4
>>
>>      aStruc[m.lnPair*2+1,1] = 'PctOf'+Ltrim(Str(m.lnPair))
>>      aStruc[m.lnPair*2+1,2] = 'B'
>>      aStruc[m.lnPair*2+1,3] = 8
>>      aStruc[m.lnPair*2+1,4] = 2
>>Endfor
>>
>>aStruc[(ANSWERCOUNT+1)*2,1] = 'Total' 
>>aStruc[(ANSWERCOUNT+1)*2,2] = 'I'
>> aStruc[(ANSWERCOUNT+1)*2,3] = 4
>>
>>*Create Cursor answers >From Array aStruc
>>
>>Create table answers From Array aStruc
>>lcText4Table =  ALLTRIM(thisform.text41.value)
>>
>>lcText4Alias = "Questions"
>>
>>IF NOT USED(lcText4Alias)
>>   SELECT 0
>>   USE (lcText4Table) ALIAS Questions
>>  ENDIF
>>
>>For ix=1 To FCOUNT(lcText4Alias) 
>>
>>    IF UPPER(LEFT(FIELDS(ix,lcText4Alias),1)) == "Q" 
>>       thisform.GetCounts(m.ix,lcText4Alias+'.'+FIELDS(ix))
>>    ENDIF
>>ENDFOR
>>Select answers
>>
>>
>>*************************************8
>>cSelect = "SELECT [sum] AS Question"
>>FOR cFlds = 2 TO FCOUNT("Answers")
>>    cFldName = FIELDS(cFlds)
>>    IF UPPER(LEFT(cFldName,7)) == "COUNTOF"
>>      cSelect = cSelect + [,] + " SUM("+FIELDS(cFlds)+") AS "+FIELDS(cFlds)
>>    ELSE
>>      cSelect = cSelect + [,] + " 0 AS "+FIELDS(cFlds)
>>    ENDIF
>>NEXT
>>cSelect = cSelect + " FROM Answers INTO ARRAY sumAnswers"
>>
>>&cSelect
>>
>>
>>SUM CountOf1 TO nTest
>>
>>INSERT INTO Answers FROM ARRAY sumAnswers
>>
>>*** The following two lines must be removed from final version too
>> GO BOTTOM
>>  MessageBox("Count Of Answer1 before Insert "+TRANSFORM(nTest)+CHR(13)+CHR(10)+;
>>"Count Of Answer1 after    Insert "+TRANSFORM(CountOf1))
>>
>>GO TOP
>>*Browse
>>Select answers
>>BROWSE
>>thisform.list1.refresh
>>thisform.refresh
>>thisform.list1.gotfocus()
>>
>>*****************************
>>gcDelimName = ALIAS( ) + '.xls'
>>gcDelimFile = PUTFILE('excel_file:', gcDelimName, 'xls')
>>IF EMPTY(gcDelimFile)  
>>   CANCEL
>>ENDIF
>>COPY TO (gcDelimFile) XLS   
>>
>>
>>
>>
>>*getcounts method
>>
>>#Define ANSWERCOUNT 20
>>#Define QUESTIONCOUNT 3
>>******************************************
>>      Local Array ans[(ANSWERCOUNT+1)*2], arrAns[1]
>>       Local lcQueField,ix,lnTotal,lnTally
>>      lcQueField = tcField
>>      ans        = 0
>>      lnTotal    = 0
>>      tctable    = LEFT(tcField, AT([.],tcField)-1)
>>
>>      Select &lcQueField,Cnt(*) ;
>>              From (m.tcTable) ;
>>      where &lcQueField between 1 and ANSWERCOUNT ;
>>      Group By 1 ;
>>      Into Array arrAns
>>
>>      lnTally = _Tally
>>      ans[1]  = SUBSTR(tcField,AT([.],tcField)+1)
>>      lnTotal = 0
>>
>>      For ix = 1 To m.lnTally
>>          lnTotal = m.lnTotal + arrAns[m.ix,2]
>>      endfor
>> 
>>      For ix = 1 To m.lnTally
>>          ans[arrAns[m.ix,1]*2]   = arrAns[m.ix,2]
>>          ans[arrAns[m.ix,1]*2+1] = arrAns[m.ix,2]/m.lnTotal * 100
>>      EndFor
>>
>>      ans[(ANSWERCOUNT+1)*2] = m.lnTotal
>>      Insert Into answers From Array ans
>>RETURN
>>
>>thanks
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform