Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2005
    Posts
    187

    Oops What the heck am I doing wrong?

    Code:
    	tPath = {Desktop="SHF_DESKTOP",
    			 DesktopCommon="SHF_DESKTOP_COMMON",
    			 QuickLaunch="SHF_APPLICATIONDATA",
    			 QuickLaunchCommon="SHF_APPLICATIONDATA_COMMON",
    			 StartMenu="SHF_STARTMENU",
    			 StartMenuCommon="SHF_STARTMENU_COMMON"
    			 }
    	-----
    	for j,path in tPath do
    		sPath = Shell.GetFolder(path);
    		Dialog.Message("Return", path.." is "..sPath);
    	end
    sPath keeps resulting in the path to my desktop (the first evaluation)!! What the heck am I doing wrong?

  2. #2
    Join Date
    Feb 2001
    Location
    Indigo Rose Software
    Posts
    2,728
    Those aren't strings, they're named constants that represent numbers.

    For example, SHF_DESKTOP is a constant that represents the number 16.

    Try this instead:
    Code:
    tPath = {Desktop=SHF_DESKTOP,
    			 DesktopCommon=SHF_DESKTOP_COMMON,
    			 QuickLaunch=SHF_APPLICATIONDATA,
    			 QuickLaunchCommon=SHF_APPLICATIONDATA_COMMON,
    			 StartMenu=SHF_STARTMENU,
    			 StartMenuCommon=SHF_STARTMENU_COMMON
    			 }
    	-----
    	for j,path in tPath do
    		sPath = Shell.GetFolder(path);
    		Dialog.Message("Return", path.." is "..sPath);
    	end
    ...and you'll see what I mean.
    --[[ Indigo Rose Software Developer ]]

  3. #3
    Join Date
    Mar 2005
    Posts
    187
    See, I knew they were number values, but I tried doing this:
    Code:
    Shell.GetPath(String.ToNumber(path));
    and it was doing the same thing. I got thrown off track because I'm actually using the string values elsewhere in my script and just assumed that since it converted the first string value ok, it'd do subsequent ones okay too.

    Which leads me to ask, why does it result the first string successfully and not the rest? Why wouldn't String.ToNumber work either?

    Anyhow, I just created 2 tables, one for the numeric value and another for strings.

    Thanks a lot Lorne!!

  4. #4
    Join Date
    Feb 2001
    Location
    Indigo Rose Software
    Posts
    2,728
    Or do a table containing tables, with both items (the string to display and the id number).

    Code:
    tPath = { {str="Desktop", id=SHF_DESKTOP}
            , {str="DesktopCommon", id=SHF_DESKTOP_COMMON}
            , {str="QuickLaunch", id=SHF_APPLICATIONDATA}
            } --etc.
    -----
    for j,path in tPath do
    	sPath = Shell.GetFolder(path.id);
    	Dialog.Message("Return", path.str.." is "..sPath);
    end
    Or just do a reverse lookup table based on the numeric values.

    Code:
    tPath = {SHF_DESKTOP="Desktop",
    			 SHF_DESKTOP_COMMON="DesktopCommon",
    			 SHF_APPLICATIONDATA="QuickLaunch",
    			 SHF_APPLICATIONDATA_COMMON="QuickLaunchCommon",
    			 SHF_STARTMENU="StartMenu",
    			 SHF_STARTMENU_COMMON="StartMenuCommon"
    			 }
    -----
    for j,path in tPath do
    	sPath = Shell.GetFolder(j);
    	Dialog.Message("Return", path.." is "..sPath);
    end
    I suspect the reason it's always returning the SHF_DESKTOP is probably just because that's what Shell.GetFolder() returns by default if you pass it a number that it doesn't recognize. I'd check the source code and tell you for sure, but I'm at home and feeling kind of lazy.
    --[[ Indigo Rose Software Developer ]]

  5. #5
    Join Date
    Dec 2003
    Location
    Location! Location!
    Posts
    6,137
    Quote Originally Posted by Lorne View Post
    Or do a table containing tables, with both items (the string to display and the id number).

    Code:
    tPath = { {str="Desktop", id=SHF_DESKTOP}
            , {str="DesktopCommon", id=SHF_DESKTOP_COMMON}
            , {str="QuickLaunch", id=SHF_APPLICATIONDATA}
            } --etc.
    -----
    for j,path in tPath do
    	sPath = Shell.GetFolder(path.id);
    	Dialog.Message("Return", path.str.." is "..sPath);
    end
    Or just do a reverse lookup table based on the numeric values.

    Code:
    tPath = {SHF_DESKTOP="Desktop",
    			 SHF_DESKTOP_COMMON="DesktopCommon",
    			 SHF_APPLICATIONDATA="QuickLaunch",
    			 SHF_APPLICATIONDATA_COMMON="QuickLaunchCommon",
    			 SHF_STARTMENU="StartMenu",
    			 SHF_STARTMENU_COMMON="StartMenuCommon"
    			 }
    -----
    for j,path in tPath do
    	sPath = Shell.GetFolder(j);
    	Dialog.Message("Return", path.." is "..sPath);
    end
    I suspect the reason it's always returning the SHF_DESKTOP is probably just because that's what Shell.GetFolder() returns by default if you pass it a number that it doesn't recognize. I'd check the source code and tell you for sure, but I'm at home and feeling kind of lazy.
    (puts on lovingly Grampa like hat, clothes, and demeanor and says)

    "That's what I like about them young folks up there, so honest!"

    Intrigued

Similar Threads

  1. Is there something wrong with Math.Floor?
    By dthompson16 in forum AutoPlay Media Studio 5.0
    Replies: 10
    Last Post: 05-27-2005, 01:57 AM
  2. My first VB DLL for AMS, or what am I doing wrong?
    By itamar in forum AutoPlay Media Studio 5.0
    Replies: 0
    Last Post: 07-25-2004, 01:56 PM
  3. Create Service (Password wrong!?)
    By BJU in forum Setup Factory 6.0
    Replies: 2
    Last Post: 02-04-2003, 11:01 AM
  4. NEED HELP ON A MESSAGE AFTER A WRONG PASSWORD
    By dragon in forum AutoPlay Menu Studio 3.0
    Replies: 0
    Last Post: 02-21-2002, 11:11 PM
  5. Something wrong with install images.!!!
    By vesta in forum Setup Factory 6.0
    Replies: 5
    Last Post: 02-03-2002, 02:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts