Hello,
I am creating a conversion wizard to copy topspeed data files to odbc data files (same structure)
What I need to attain is to avoid repeating the same code so I tried to create a procedure passing the file parameter and record parameter. With that, I can only call the procedure without repeating the code.
CopyTPS2SQL PROCEDURE (FILE pTPS,FILE pSQL,*STRING pTpsRecord,*STRING pSQLRecord,STRING pProgressText,LONG pProgressBar,UNSIGNED pFeq) ! Declare Procedure
! Start of "Data Section"
! [Priority 1300]
! [Priority 4000]
TotalRecords LONG
! End of "Data Section"
! Start of "Local Data After Object Declarations"
! [Priority 5000]
! End of "Local Data After Object Declarations"
CODE
! Start of "Processed Code"
! [Priority 4000]
TotalRecords = RECORDS(pTPS)
pProgressBar = 0
pFeq{PROP:RangeHigh} = TotalRecords
pProgressText = 'Progress: 0/' & TotalRecords & ' Copied'
DISPLAY
LOGOUT(5,pSQL)
SET(pTPS)
LOOP
NEXT(pTPS)
IF ERRORCODE() THEN BREAK END
pSQLRecord :=: pTPSRecord
ADD(pSQL)
pProgressBar += 1
pProgressText = 'Progress: ' & pProgressBar & '/' & TotalRecords & ' Copied'
DISPLAY
YIELD()
END
COMMIT()
In the procedure above, I passed the file record to a STRING.
Code below is how I call the procedure from above
!START OF USERINFO
ProgressBar2 += 1
ProgressText2 = 'Progress: Converting UserInfo Record'
DISPLAY()
OPEN(UserInfov4T)
IF NOT ERRORCODE()
Access:UserInfo.Open
Access:UserInfo.UseFile
IF RECORDS(UserInfov4T)
CopyTPS2SQL(UserInfov4T,UserInfo,UserInfov4T:Record,UserInfo:Record,ProgressText3,ProgressBar3,?ProgressBar3)
END
Access:UserInfo.Close
CLOSE(UserInfov4T)
END
!END OF USERINFO
This procedure of copying works. However, deep assignment does not work as it is used to be.
Here is the tps file record
And here is the ODBC(MySQL) file record converted
I am wondering for better approach to this concern. I hope the community helps me regarding this.
Thank you for your kind assistance.