Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Character type
Message
De
06/03/2007 04:17:25
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Character type
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP
Database:
Visual FoxPro
Divers
Thread ID:
01200957
Message ID:
01200957
Vues:
57
hi all,
1.i import excel sheet to vfp.dbf ,
every fields have name begin with Q is a characters type,
to run this code under, i must convert all fields to numbers type,
is ther a way to run this code if fields at my table is characters or numbers,

2.at the same table i have a field (session_number) from 1 to 10,
i need to run this code for every session aloan and save it as new table as session1.dbf ,session2.dbf to.....session10.dbf

3.i need to convert all tables from session1.dbf to session10.dbf to excel sheet.
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 table answers From Array aStruc
lcText4Table =  ALLTRIM(thisform.text41.value)

lcText4Alias = "Questions"

IF NOT USED(lcText4Alias)
   SELECT 0
   USE (lcText4Table) ALIAS Questions
   SET FILTER TO session_nu=1
ENDIF
*SET FILTER TO session_nu=1
*brow
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


 GO BOTTOM
  MessageBox("Count Of Answer1 before Insert "+TRANSFORM(nTest)+CHR(13)+CHR(10)+;
"Count Of Answer1 after    Insert "+TRANSFORM(CountOf1))

GO TOP
Select answers

*****convert (session1.dbf to session10.dbf) to excel sheets*****
gcDelimName = ALIAS( ) + '.xls'
gcDelimFile = PUTFILE('excel_file:', gcDelimName, 'xls')
IF EMPTY(gcDelimFile)  
   CANCEL
ENDIF
COPY TO (gcDelimFile) XLS   
 
thanks
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform