Yeah, use Dennis code. Better to check if one is there, just in case..
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Dennis
> McGrath
> Sent: Friday, July 25, 2014 1:20 PM
> To: RBASE-L Mailing List
> Subject: [RBASE-L] - RE: Path of User's Desktop
>
> Doug,
>
> SLOC is working correctly.
>
> I suggest you change your code to:
>
> set var vInt int = 0
> set var vInt = (SLOC(.strpath, (CHAR(0))) if vint > 0 then
> SET VAR gUserDeskTop = (SGET(.strpath, (.vInt - 1), 1)) else
> SET VAR gUserDeskTop = (TRIM(.strpath)) endif
>
> and try tracing with watch variables to see what is happening
>
>
> From: [email protected] [mailto:[email protected]] On Behalf Of Doug
> Hamilton
> Sent: Friday, July 25, 2014 12:00 PM
> To: RBASE-L Mailing List
> Subject: [RBASE-L] - Path of User's Desktop
>
> Back Jan '11, Mike Byerley posted a small RBase routine using stdcall
> to get the path to the user's desktop.
> It has worked flawlessly until I did some testing yesterday on a
> routine that uses Mike's code. The entire code is below for context,
> but the specific command where the path is lost is:
> SET VAR gUserDeskTop = (SGET(.strpath, ((SLOC(.strpath, (CHAR(0)))) -
> 1), 1))
>
> Variable strpath is predefined as 260 null characters.
> The correct path is returned in the variable strpath; the SGET's
> purpose is extract just the path from the 260 characters (path + nulls)
> that was returned by the dlcall.
> However, it appears that strpath is already trimmed of trailing nulls -
> or any other characters that I've tried predefining in strpath. Hence
> the SLOC chokes and gUserDeskTop that is returned is blank.
> So I guess the question is: Are trailing characters automatically
> trimmed in the dlcall?
> Is this a fluke on my system or a permanent update for which I should
> remove the SGET command?
> Is this a change in a Win 7 update or an RBase update? I've scanned 4
> What's New in R:Base looking for "trim" and "trail" but couldn't find
> any relevant references.
>
> RBase 9.5.4.30717 (32)
> Win 7, SP1
>
> Just wondering what the best course of action should be.
> TIA,
> Doug
>
> --UserDesktop.RMD get full path to user's desktop --Courtesy Mike
> Beyerly, 01/13/11 {demo of SHGetSpecialFolderPath function mbyerley
> 6/1/2008 }
>
> SET VAR max_path INTEGER = 260
> SET VAR lngfolderfound INTEGER = NULL
> SET VAR strpath TEXT = NULL
> SET VAR gUserDeskTop TEXT = NULL
> IF (chkfunc('SHGetSpecialFolderPathA')) = 0 THEN
> STDCALL function 'SHGetSpecialFolderPathA' alias
> 'SHGetSpecialFolderPath' +
> (integer, integer, ptr text (260), integer) : integer ENDIF
>
> SET VAR lngfolder = 16
> { Set the variable as a BUFFER of MAX_PATH Characters filled with
> Nulls. The
> VAR is passed by Reference and is filled with the PATH in the
> function. When
> VARs are created this way, you can't trim the length, so we look for
> the first
> NULL (Char(0)) in the returned value and SGET everything up to that
> value
> to COPY to the VAR specfolder. As Simple as that. If you wanted to
> Create the
> Special Folder if it is NOT FOUND, you would change the first 0 in
> the DLCALL
> argument to a NON ZERO value.
> }
>
> -- CREATE the BUFFER of length max_path for SET VAR strpath =
> (SFIL((CHAR(0)), .max_path))
>
> SET VAR lngfolderfound = +
> (dlcall('Shell32','SHGetSpecialFolderPathA', 0, lngfolder, strpath,
> 0))
>
> IF lngfolderfound > 0 THEN
> -- The strpath var has to be SGET to omit the trailing nulls from the
> BUFFER
> SET VAR gUserDeskTop = (SGET(.strpath, ((SLOC(.strpath, (CHAR(0)))) -
> 1), 1)) ENDIF
>
> CLEAR VAR +
> lngfolder, +
> lngfolderfound, +
> max_path, +
> strpath
>
> RETURN
>
> ________________________________________
>
> This email is free from viruses and malware because avast! Antivirus
> protection is active.