Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What could cause error on this line
Message
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01526039
Message ID:
01526069
Views:
106
This message has been marked as the solution to the initial question of the thread.
Here is a simple proof of concept - I generated the output based on this test program (before the output):
LOCAL lcFields, lcValues, lcTable, lnFields, lnI, lcOutput
LOCAL ARRAY laFields[1]
CLOSE DATABASES ALL 
#define CRLF CHR(13) + CHR(10)

CREATE CURSOR csrTables(TableName C(20))

INSERT INTO csrTables VALUES ('ItemTreeLog')
INSERT INTO csrTables VALUES ('WebPages')
lcOutput =''
lcTable = ALLTRIM(TableName)

SCAN 
  USE (m.lcTable) IN 0 ALIAS WorkTable
  lnFields = AFIELDS(laFields, 'WorkTable')

STORE '' TO lcFields, lcValues

FOR lnI = 1 TO lnFields

   lcFields = m.lcFields + IIF(EMPTY(m.lcFields),'',', ') + CRLF + laFields(m.lnI,1)
   lcValues = m.lcValues + IIF(EMPTY(m.lcValues),'',', ') + CRLF + '?' + m.lcTable + '.' + laFields(m.lnI,1)
NEXT

TEXT TO lcOutput TEXTMERGE NOSHOW additive
   USE <<m.lcTable>>
   SCAN 
   <<'TEXT'>> TO lcInsert NOSHOW
      INSERT INTO <<m.lcTable>>
      ( <<m.lcFields>>
       )
      VALUES 
      (<<m.lcValues>>
       ) 
   END<<'TEXT'>>
   
   SQLCONNECT(hConn, m.lcInsert)    
   
   ENDSCAN
   
   
ENDTEXT    
USE IN SELECT('WorkTable')
SELECT csrTables
lcTable = ALLTRIM(csrTables.TableName)
ENDSCAN     
    


_cliptext = m.lcOutput

*** OUTPUT ***

   USE WebPages
   SCAN 
   TEXT TO lcInsert NOSHOW
      INSERT INTO WebPages
      ( 
VERSION,
FILENAME,
CONTENTS
       )
      VALUES 
      (
?WebPages.VERSION,
?WebPages.FILENAME,
?WebPages.CONTENTS
       ) 
   ENDTEXT
   
   SQLCONNECT(hConn, m.lcInsert)    
   
   ENDSCAN
   
      USE ItemTreeLog
   SCAN 
   TEXT TO lcInsert NOSHOW
      INSERT INTO ItemTreeLog
      ( 
DATE_TIME,
METHOD,
MESSAGE,
SALESPOINT,
OPERATOR,
CODE,
LONGMSG
       )
      VALUES 
      (
?ItemTreeLog.DATE_TIME,
?ItemTreeLog.METHOD,
?ItemTreeLog.MESSAGE,
?ItemTreeLog.SALESPOINT,
?ItemTreeLog.OPERATOR,
?ItemTreeLog.CODE,
?ItemTreeLog.LONGMSG
       ) 
   ENDTEXT
   
   SQLCONNECT(hConn, m.lcInsert)    
   
   ENDSCAN
>>>I agree with everything you are saying. And just for the heck of it (even though VFP does not recommend) I will try to use TEXTMERGE within TEXTMERGE just to see what comes out. Stay tuned.
>>
>>It is actually quite simple after I thought about it.
>>
>>The above is the idea from the top of my head, you may need just some slight changes.
>
>No, this will not work. Nexted TEXT TEXTMERGE do not work. What happens is that after the TEXT MERGE for lcInsert, the line SCAN m.lcTable (with brackets) gets error.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform