>Update,
>Yes sir, This PRG is the slowest Part of my Entire Process. Here it is.
I am always saying to do a task one way every time.
There is no need to GO TOP before a SCAN. If there is a filter on the table, which is true even with SET DELETED ON, the GO TOP will be slow. If you absolutely need to GO TOP, use LOCATE.
I think you should also learn that macro-substitution is to be avoided as much as possible. It is a simple variable that you need. You should not need to start the FoxPro interpreter for such a trivial thing.
> apSetFunc(id, AP_Set_Input , 0, 0, '&iFilename' , 0) &&input file.
apSetFunc(id,AP_Set_Input,0,0, chr(39) + m.iFileName + chr(39), 0)
Can you call id=apCreate once before the loop and then ask it to convert the files? Starting up apCreate multiple times may be a waste.
>
>
>DECLARE INTEGER _apCreate@0 IN ps2pdf.dll AS apCreate
>DECLARE _apClose@4 IN ps2pdf.dll AS apClose INTEGER id
>DECLARE INTEGER _apConvert@4 IN ps2pdf.dll AS apConvert INTEGER id
>DECLARE INTEGER _apSetFunc@24 IN ps2pdf.dll AS apSetFunc INTEGER id, INTEGER code, INTEGER nOptVal1, INTEGER nOptVal2, STRING pOptVal1, STRING pOptVal2
>DECLARE INTEGER _apGetFunc@24 IN ps2pdf.dll AS apGetFunc INTEGER id, INTEGER code, INTEGER nOptVal1, INTEGER nOptVal2, STRING pOptVal1, STRING pOptVal2
>#define AP_Set_Output 3000
>#define AP_Set_Input 3001
>SELECT Convert
>GO top
>SCAN
>** Convert ps files to a general pdf file.
>iFilename=ALLTRIM(oldpath)
>oFilename=ALLTRIM(Newpath)
>id = apCreate()
>IF (id # 0)
> apSetFunc(id, AP_Set_Input , 0, 0, '&iFilename' , 0)
> apSetFunc(id, AP_Set_Output, 0, 0, '&oFilename', 0)
> iRet = apConvert(id)
> apClose(id)
>ENDIF
>ENDSCAN
>
>
>
>The process is taking ample time and my objective is to reduce it to minimum (by multi threading or otherwise)
>
>Regards
>
>
>>>I have an application written in VFP-9. The said applications has MENU, Forms, PRG etc.
>>>Oneof the PRG requires Scan-Endscan loop and in between that conversion of Data.
>>>
>>>It takes a lot time even on fully loaded I-7 PC. Some expert suggested me to use Multi thread.
>>>
>>>Is is possible to convert my application existing application to MT application so that the performance could enhance.
>>>
>>>Anybody having Idea , kindly guide.
>>>
>>>Regards
>>
>>I have seen many examples of programmers wasting CPU cycles. For example
>>
>>SCAN ALL
>> IF this and that
>> replace field with something
>> endif
>>
>> if not this and not that
>> replace field with somethingelse
>> endif
>>ENDSCAN
>>
>>It is much faster to optimize that
>>
>>REPLACE field with something for this and that
>>REPLACE field with somethingelse for not this and not that.
>>
>>In other words, are you scanning all records and calling the conversion of data or are you targeting the conversion? If I remember correctly, you are trying to convert PDF files? You can improve things by declaring the dlls at the start of the entire process rather than at each file....
>>
>>Is the one PRG the slowest part of your system? If so, post that prg and let's see what can be done.