Simply Maya User Community

Simply Maya User Community (https://simplymaya.com/forum/index.php)
-   Programming (https://simplymaya.com/forum/forumdisplay.php?f=32)
-   -   load variables from a text file (https://simplymaya.com/forum/showthread.php?t=42055)

uncharming 22-02-2016 11:53 PM

load variables from a text file
 
hello everyone, I need your help.
As indicated in the title, I want to load variables from a text file. I'm writing a single script.
At first, I generate a text file "C:/tmp/variable.txt" , (with a fopen) in which there is this:

string $VARMAX[] = {"nurbsSphere1","pCube1","nurbsCone2"};

secondly, I load it:
source "C:/tmp/variable.txt";
print $VARMAX;


it is now that the problem happens. If my file "C:/tmp/variable.txt" doesn't yet exist, Maya will tell me 'Cannot find file'. Logic.

So I try to put the command in a 'evalEcho',

pause -sec 1;
evalEcho "source \"C://xdk//variable.txt\";";
print $VARMAX;


I have this message: // Error: Line 3.14: "$VARMAX" is an undeclared variable. //
as if it was a procedure.

I need to have this text file to use it instantly or later.


All times are GMT. The time now is 08:03 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Simply Maya 2018