Download

Getting Environment variable from system

Hi, I’ve tried to google it but couldn’t find a good example on the internet apart from the official documentation which doesn’t have any example
https://docs.unrealengine.com/en-US/…e/1/index.html

I’m trying to get an environment variable like so :



#include "GenericPlatform/GenericPlatformMisc.h"

FBXConvertAsync::FBXConvertAsync(FString input, FString output, FFBXCreated& callback) : inputFile(input), outputFile(output), callback(callback)
{
    FString invesalius = FGenericPlatformMisc::GetEnvironmentVariable(*FString("INVESALIUS_PATH"));
    FString vroscopy_python_files = FGenericPlatformMisc::GetEnvironmentVariable(*FString("VROSCOPY_PY"));

    UE_LOG(LogTemp, Warning, TEXT("Environment variable - invesalius_path = %s"), *invesalius)
    UE_LOG(LogTemp, Warning, TEXT("Environment variable - vroscopy_py = %s"), *vroscopy_python_files)
}

However, the returned variables are empty (they exist on my machine)

hope someone can give me some insight!

Thanks, Eden

Problem solved

Used



 FBXConvertAsync::INVESALIUS_PATH = FWindowsPlatformMisc::GetEnvironmentVariable(*FString("INVESALIUS_PATH"));    
 FBXConvertAsync::PYTHON_FILES_PATH = FWindowsPlatformMisc::GetEnvironmentVariable(*FString("VROSCOPY_PY"));  


**FWindowsPlatformMisc **instead of FGenericPlatformMisc

Didn’t know about this library until I stumbled upon an obscure page on google… (thanks to this site Is It A Drive? Is It A Directory? No, It’s… - Blog : Coconut Lizard)

Hopefully this is gonna help someone in the future