FTP Download and scope...

Hi Guys, It's been a long time since i needed your help, but i'm stuck with a scope issue for my license script.

I'll Try to explain:
- I've got a mse file, with a few critical functions and a variable into.
- The script download the file into a specific folder,then i call "FileIn Thefile" and the next line is supposed to execute a function found into this file.
-If i launch max, and evaluate the script, the function is not found, but if i evaluate it a second time, the function is found and the script continue... A classic scope issue.

Here is the code:

--Download Usefull Function and execute from server
local targetfunction = ("RF_DecryptFunction.mse")
local tempfunction = (getdir #userscripts + "\RF_DecryptFunction.mse")
download targetfunction tempfunction
FileIn tempfunction
deletefile tempfunction
free targetfunction
free tempfunction

I've read about the difference between filein and include, but don't understand the main differences.

Once this part evaluated, i just want to use some functions i thought stocked into RAM (== Globals ? ) and free them right after.

Thanks.

Florent.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
locke's picture

Hi, I know i don't have many

Hi, I know i don't have many replies regarding my issue with my download function.

In fact, i do this to protect the use of my scripts without my knowledge; I've had some bad experiences where once the script made, i'm gently pushed away from the company, and the client just use my work indefinitely. I need to protect my work for a future use, and i guessed that an internet check should be the easiest way.

Does anyone here knows a way to disable a script, or protect it from a non wanted use ?

Kind Regards,

Florent.

locke's picture

Finally Return

I corrected the script, i had to use Include instead of Filein, and it can smoothly read the functions into the mse File.

I had to use a literal expression so i use the C:/User/public folder.

But, i understand earlier that as you said, i'm having troubles for my download function;
I tried to understand the explanation from Jos Balcaen (http://josbalcaen.com/ftp-upload-maxscript/)

I just changed the UploadAsync for DownloadAsync... Maybe not a smart move. Here is my function:

fn download externalfile localfile =
(
webClient = dotnetObject "System.Net.WebClient"
webClient.Credentials = dotnetObject "System.Net.NetworkCredential"\
"MYUSER" "MYPASSWORD"
theUri=dotnetObject "System.Uri" \
("http://ftp.[ADDRESS]"+ externalfile)
webClient.DownloadFile theUri localfile
)

Si into my script i have:

--First Part
gc light:true delayed:true
--Download Useful functions and execute from server
local targetfunction = ("\\RF_DecryptFunction.mse")
local tempfunction = "C:\Users\Public\RF_DecryptFunction.mse"
download targetfunction tempfunction
--
 
--Second PArt
If doesFileExist "C:\Users\Public\RF_DecryptFunction.mse" do
(
try (Include "C:\Users\Public\RF_DecryptFunction.mse") catch (print "Damned")
)
--

If i just launch the full script, it crashed, the file is downloaded at the end of the script, not when i call it.

If i Launch the first, then the second, everything runs as i want to.

I don't understand much about the dot-net classes and functions. I may have a way to download the file, wait until it's done, and continue. But i don't know how to use the return from the dotnetobject...

locke's picture

Hi, thank you both for your

Hi,
thank you both for your replies.

I Just tried to copy the file into (getdir #userscripts + "\\RF_DecryptFunction.mse") to just execute the code without the downloading part. It Still Fails.

I tried to declare global vars into the Decryptfunction file:

global decryptmessage
global licencenbtodll
 
fn decryptmessage encryptedmessage refkey encryptionkey =
(
)
 
fn licencenbtodll = 
(
)
 
global refkey = #()

It Didn't work with FileIn.

I'll try to find some time to look the link Pixamoon posted.

Thanks,

Best Regards.

Florent.

miauu's picture

.

To use the functions written in "RF_DecryptFunction.mse" you must knot the name of those functions. No matter if you use include or fileIn, if you don't know the name of the functions you can't use them.

pixamoon's picture

`

hi,

first please use double "\\" in "\RF_DecryptFunction.mse" -> "\\RF_DecryptFunction.mse"

"\R" is a carriage return character

And your issue - I think it depends of download function. Maybe file is still locked after download and can not be started.

what you can do:
- download file to temp,
- wait till is downloaded,
- copy to correct location,
- delete temp file
- run by "filein" or "include"

to "include" script from custom location take a look here:
http://www.scriptspot.com/forums/3ds-max/general-scripting/include-funct...

also to run function by "filein" - I think function needs to be global eg:

global newFunction01
fn newFunction01 = 
(
   --...
)

than it will be visible by rest of your script

"include" should just include the function inside your code

Best,
Pixamoon

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.