Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can VFP determine MS Project version on a file
Message
 
To
11/02/2002 17:49:58
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00618395
Message ID:
00618746
Views:
11
>>>The brute force approach could be to open the MPP file using the LLFF and read the first 5000 bytes of the file. The string "Microsoft Project 9.0" will be there for Project 2000. "Microsoft Project 8.0" will be there for Project 98.
>>>
>>>HTH.
>>
>>This code seemed to work OK:
>>
>>lcheck = FILETOSTR('C:\Temp\Project2.mpp')
>>llcontinue = .F.
>>FOR i = 1 TO 6000
>>  IF UPPER(SUBSTR(lcheck,i,17)) = 'MICROSOFT PROJECT'
>>    lcFound = SUBSTR(lcheck,i,21)
>>    EXIT
>>  ENDIF
>>ENDFOR
>>
>>IF NOT EMPTY(lcFound)
>>  RETURN(lcFound)
>>ELSE
>>  RETURN('Unknown')
>>ENDIF
>>
>
>The probable reason Larry was asking about performance is the size of the project, and the For/Next loop. The size can be neglected, if you use just the first 6000 bytes, and the speed will improve if you use no loop:
>
>
>nGFH = fopen('C:\Temp\Project2.mpp')
>lcCheck=fread(nGFH, 6000)
>fclose(nGFH)
>lFound = .F.
>#define C_MSP 'MICROSOFT PROJECT'
>FOR i = 1 TO occurs(c_msp, lcCheck)
>  nFoundAt=atc(c_msp, lcCheck)
>  if "8.0" $ substr(lcCheck,i,21)
>    lFound=.t.
>    EXIT
>  ENDIF
>ENDFOR
>return lFound
>ENDIF
>
>This should be faster.

Thanks Dragan, I was working on the code using fopen/fread to test against my previous post. Your ideas will come in handy. I will post my findings about speed testing. Thanks again.
Bret Hobbs

"We'd have been called juvenile delinquents only our neighborhood couldn't afford a sociologist." Bob Hope
Previous
Reply
Map
View

Click here to load this message in the networking platform