Normal Topic @GetLocalEnvVar(evar) (Read 1599 times)
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
@GetLocalEnvVar(evar)
Mar 13th, 2018 at 11:27pm
Print Post Print Post  
Hello, I'm trying to use @GetLocalEnvVar(evar) and it doesn't seem to be working right.

Here is/was my working code:

Code
Select All
var vName as String
var vUser as String
var vFolder as String

If @Mode() = 0 or @Mode() = 1
{
	vName = Record_ID
	vUser = @Del(@GetLocalEnvVar("HOMEPATH"), 1, 7)
	vFolder = "C:\Users\" + vUser + "\Google Drive\AAction Photos\" + vName
}
 



As you can see, I'm using the Windows Environment Variable HOMEPATH which returns:

Code
Select All
 \Users\{username}
 



What's strange is that it worked the first few times I used it, everything was working perfectly. Even used WriteLn() to check it to make sure it was returning the string I wanted. However, I ran into Sesame crashing and locking a record when I ran the program (@Shell()) so I closed it out, and ran Sesame as administrator by default, but now it won't run at all. Either in Sesame Designer or Sesame Client. Not sure what went wrong.
  
Back to top
 
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: @GetLocalEnvVar(evar)
Reply #1 - Mar 13th, 2018 at 11:31pm
Print Post Print Post  
Also, I tried turning off Windows Firewall and AntiVirus to see if it would work, and there was no change.
  
Back to top
 
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: @GetLocalEnvVar(evar)
Reply #2 - Mar 14th, 2018 at 2:11pm
Print Post Print Post  
Turns out, it works fine running on the local computer on Sesame Designer, but when running it through the Server environment on a client it doesn't work. I'm not sure why this is, but I think the code is looking at the Server Environment and not the Local Environment. In which case, I need a way to force it to look at the Local environment at least for some aspects of the code.

One of the things that caused it not to work in my previous post, is I changed the shortcuts for Sesame and Sesame Designer to run as administrator thinking that would help, but all kinds of weird things happened. Word Merge didn't work right, it would open Word without my settings or Macros. When I printed HTML preview reports it would open in a different version of Google Chrome rather than my default user. And etc. I'm not sure why that is. But I changed both shortcuts back to how they were, to run as regular. Now trying to figure it out from the code side.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: @GetLocalEnvVar(evar)
Reply #3 - Mar 14th, 2018 at 2:15pm
Print Post Print Post  
actiontech wrote on Mar 13th, 2018 at 11:27pm:
However, I ran into Sesame crashing and locking a record when I ran the program (@Shell()) so I closed it out, and ran Sesame as administrator by default, but now it won't run at all



I would be willing to bet that it wasn't a crash. @Shell() is not asynchronous so Sesame will appear as locked until the shell command is finished as we are waiting for the response from it. Use @ASynchShell() if you want Sesame to just fire off the command and continue on with life. No need to run Sesame as an Administrator.

Rather then hardcoding the "c:\Users\" portion, why not just use the Env variable USERPROFILE instead which will return 'c:\Users\UserName' or 'C:\Documents and Settings\UserName' on older versions of Windows.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: @GetLocalEnvVar(evar)
Reply #4 - Mar 14th, 2018 at 2:26pm
Print Post Print Post  
actiontech wrote on Mar 14th, 2018 at 2:11pm:
but when running it through the Server environment on a client it doesn't work. I'm not sure why this is, but I think the code is looking at the Server Environment and not the Local Environment. In which case, I need a way to force it to look at the Local environment at least for some aspects of the code.


What do you mean by "Server environment on a client"? Sbasic runs on the client side with the exception of programmed retrieve specs, Mass Update on the Engine, and maybe another very specialty case that I can not recall. The command @GetLocalEnvVar() gets the Client or Standalone environment variable and @GetServerEnvVar() gets the named  environment variable from the Server.

Quote:
And etc. I'm not sure why that is.

I'd be willing to bet it was because Sesame was not running as You(Your User Account) so when Sesame asks the OS for things such as the default .HTM handler, what's returned would not necessarily be the same as Your default .HTM handler.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
actiontech
Full Member
***
Offline



Posts: 173
Joined: Apr 10th, 2016
Re: @GetLocalEnvVar(evar)
Reply #5 - Mar 23rd, 2018 at 9:42pm
Print Post Print Post  
Turns out @GetLocalEnvVar(evar) works great for adding and removing files from my Synced folder. (Across Server and Client computers). It also works great for viewing the general contents of said folder. But when it comes to actually viewing the picture in an Image Box, you run into a problem. Image path.

I found that the way to correct this in those instances was to use these two commands:

Code
Select All
@GetServerEnvVar(vFolder)
SetAltImagePath(View_Picture_Box, vFolder)
 



Now it works great. Thanks for all the help.
  
Back to top
 
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: @GetLocalEnvVar(evar)
Reply #6 - Mar 26th, 2018 at 1:28pm
Print Post Print Post  
That is because Image boxes(and Static image elements) are pathed from the Server.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged