error XS9061: The "PTR(..) operation" is not allowed for method or function calls

Deutschsprachiges X#-Forum – German language forum

Moderator: wriedmann

Post Reply
Tudorf
Posts: 50
Joined: Wed Feb 08, 2023 3:43 pm

error XS9061: The "PTR(..) operation" is not allowed for method or function calls

Post by Tudorf »

Hallo

Ich versuche als Hobbyprogrammierer mein VO2.8 auf X# umzustellen.

Mit Pointern habe ich keine Ahnung und habe da immer nur ferige Routinen eingesetzt.

Wie kann ich das Problem lösen?

error XS9061: The "PTR(..) operation" is not allowed for method or function calls. If the method or function returns a pointer then consider using the (<Type> PTR) syntax instead.

in Zeile: pszDrives := PTR( BYTE, MemAlloc( dw ) )

Code: Select all

FUNCTION FabGetLogicalDrivesArray( lDriveOnly ) AS ARRAY
//g Files,Files Related Classes/Functions
//g Drives,Drives related Classes/Functions
//d Retrieve all existing drives, and return an array with/without drives type \line
//d  If lDriveOnly is True :\line
//d  { { "A" }, { "C" }, { "D" }, { "K" } }\line
//d If lDriveOnly is False\line
//d  { { "A", DRIVE_REMOVABLE }, { "C", DRIVE_FIXED }, { "K", DRIVE_REMOTE } }\line
 LOCAL dw  AS DWORD
 LOCAL pszDrives AS BYTE PTR
 LOCAL aRet  AS ARRAY
 LOCAL aTemp  AS ARRAY
 LOCAL wCpt  AS WORD
 LOCAL bByte  AS BYTE
 LOCAL cDrv  AS STRING
 //
 Default( @lDriveOnly, FALSE )
 //
 dw := GetLogicalDriveStrings( 0, null_ptr )
 pszDrives := PTR( BYTE, MemAlloc( dw ) )
 //
 GetLogicalDriveStrings( dw, pszDrives )
 //
 aRet := {}
 cDrv := ""
 FOR wCpt := 1 TO dw
  //
  bByte := pszDrives[ wCpt ]
  IF ( bByte != 0 )
   cDrv := cDrv + Chr( bByte )
  ELSE
   IF ( cDrv == "" )
    // We should point on the last caracters, the FOR loop will end
   ELSE
    IF lDriveOnly
     aTemp := { Upper( cDrv ) }
    ELSE
     aTemp := { Upper( cDrv ), GetDriveType( String2Psz( cDrv ) ) }
    ENDIF
    //
    AAdd( aRet, aTemp )
    cDrv := ""
   ENDIF
  ENDIF
 NEXT
 //
 MemFree( pszDrives )
 //
RETURN aRet
Danke Martin
User avatar
wriedmann
Posts: 4106
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Re: error XS9061: The "PTR(..) operation" is not allowed for method or function calls

Post by wriedmann »

Hallo Martin,
die Fab-Bibliotheken hat Fabrice als Mitglied des X#-Entwicklungsteams selber nach X# portiert:
https://fabtoys.net/
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply