include function ERROR = '-- Compile error: include expected filename string' [SOLVED]

Hi all,

This works:

	srchDir = GetDir #scripts
	scripts = getfiles (srchDir + "\\" + "CoronaConverter_v*.ms")
	sort scripts
	CoronaConverterlatest = scripts[scripts.count]
 
	global CoronaConverterGUI = try(CoronaConverterNoGui = true)catch()
	global CoronaConverterMacro = try(macros.run "Corona Renderer" "CoronaConverter")catch()
 
if CoronaConverterMacro != false then (
	CoronaConverterlatest
	try(include "C:\Program Files\Autodesk\3ds Max 2015\scripts\coronaConverter_v1.12.ms")catch()
	try(CoronaConverter.destroyGui())catch()
	StartCoronaConverter
	CoronaConverter.converterSettings.switchRenderEngine = true
	CoronaConverter.converterSettings.printInfo = true
	CoronaConverter.converterSettings.silent = true
	CoronaConverter.converterSettings.useTryCatchBugReporting = true
 
	CoronaConverter.converterTools.resetMtlEdit()
	CoronaConverter.converterTools.SetMaxDisplacementLevel 1.0
	CoronaConverter.converterTools.showMapsInVP true
 
	CoronaConverter.convertScene()
)
gc()

But when I change:

try(include "C:\Program Files\Autodesk\3ds Max 2015\scripts\coronaConverter_v1.12.ms")catch()

To:

try(include CoronaConverterlatest)catch()

It doesn't work with the error described in the subject.

Although running:

	CoronaConverterlatest
	include CoronaConverterlatest 

after the fact runs just fine.

Has anyone came across a similar problem before. Thanks.

Script which this code runs is found on the Corona forum here & here:
https://corona-renderer.com/forum/index.php/topic,126.0.html
http://www.racoon-artworks.de/?p=154

Comments

Comment viewing options

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

still waiting for the

still waiting for the ultimate solution that will work independently, hoping that its on its way and will show by eventually.

3dwannab's picture

Thanks but this but it comes

Thanks but this but it comes back with the same type error. I think its from running it inside the then ()
WORKS:

	strDir = GetDir #scripts
	scripts = getfiles (pathconfig.normalizepath (strDir + "\\CoronaConverter_v*.ms"))
	global CoronaConverterGUI = try(CoronaConverterNoGui = true)catch()
	global CoronaConverterMacro = try(macros.run "Corona Renderer" "CoronaConverter")catch()
	CoronaConverterNoGui = true
	--include scripts[scripts.count]
 
if CoronaConverterMacro != false then try(
 
	--if scripts.count > 0 then include scripts[scripts.count]
	include "coronaConverter_v1.12.ms"
	--try(CoronaConverter.destroyGui())catch()
	StartCoronaConverter
	CoronaConverter.converterSettings.switchRenderEngine = true
	CoronaConverter.converterSettings.printInfo = true
	CoronaConverter.converterSettings.silent = true
	CoronaConverter.converterSettings.useTryCatchBugReporting = true
 
	CoronaConverter.convertScene()
 
	CoronaConverter.converterTools.resetMtlEdit()
	CoronaConverter.converterTools.SetMaxDisplacementLevel 1.0
	CoronaConverter.converterTools.showMapsInVP true
 
)catch()
gc()

DOESN'T (This is strange) (just the single lines blocked swapped)

	strDir = GetDir #scripts
	scripts = getfiles (pathconfig.normalizepath (strDir + "\\CoronaConverter_v*.ms"))
	global CoronaConverterGUI = try(CoronaConverterNoGui = true)catch()
	global CoronaConverterMacro = try(macros.run "Corona Renderer" "CoronaConverter")catch()
	CoronaConverterNoGui = true
	--include scripts[scripts.count]
 
if CoronaConverterMacro != false then try(
 
	if scripts.count > 0 then include scripts[scripts.count]
	--include "coronaConverter_v1.12.ms"
	--try(CoronaConverter.destroyGui())catch()
	StartCoronaConverter
	CoronaConverter.converterSettings.switchRenderEngine = true
	CoronaConverter.converterSettings.printInfo = true
	CoronaConverter.converterSettings.silent = true
	CoronaConverter.converterSettings.useTryCatchBugReporting = true
 
	CoronaConverter.convertScene()
 
	CoronaConverter.converterTools.resetMtlEdit()
	CoronaConverter.converterTools.SetMaxDisplacementLevel 1.0
	CoronaConverter.converterTools.showMapsInVP true
 
)catch()
gc()

Does the script variable need to be made a global do you think?

pixamoon's picture

`

I don't have corona installed, check where is the CoronaConverter_v1.12.ms file located.

maybe not in #Scripts but #UserScripts

3dwannab's picture

It's in the right place all

It's in the right place all right. In scripts inside the max directory.

pixamoon's picture

`

oki, try this:

scripts = getfiles (pathconfig.normalizepath (GetDir #scripts+ "\\CoronaRenderer\\CoronaConverter_v*.ms"))

I think you forgot about folder \CoronaRenderer\

pixamoon's picture

`

oki, I found this: after Include can be only string literal in ""
maxscript help :"... file name specification must be a string literal, and not a variable or an expression."

what you can do is find newest filename, create temporary include script with found name and include it into your code:

local str = stringStream ""
format "include  %" scripts[scripts.count] to:str
execute str

whole code will look:

	scripts = getfiles (pathconfig.normalizepath (GetDir #scripts + "\\CoronaConverter_v*.ms"))
	MakeDir "C:\\Temp"
	(dotnetClass "System.IO.File").WriteAllLines "C:\\Temp\\tmp_include.ms" #("include \"" + scripts[scripts.count] as string + "\"")	
 
	global CoronaConverterGUI = try(CoronaConverterNoGui = true)catch()
	global CoronaConverterMacro = try(macros.run "Corona Renderer" "CoronaConverter")catch()
	CoronaConverterNoGui = true
 
if CoronaConverterMacro != false do try(
	include "C:\\Temp\\tmp_include.ms"
 
	--include "C:\Program Files\Autodesk\3ds Max 2014\scripts\coronaConverter_v1.13.ms"
	--try(CoronaConverter.destroyGui())catch()
	StartCoronaConverter
	CoronaConverter.converterSettings.switchRenderEngine = true
	CoronaConverter.converterSettings.printInfo = true
	CoronaConverter.converterSettings.silent = true
	CoronaConverter.converterSettings.useTryCatchBugReporting = true
 
	CoronaConverter.convertScene()
 
	CoronaConverter.converterTools.resetMtlEdit()
	CoronaConverter.converterTools.SetMaxDisplacementLevel 1.0
	CoronaConverter.converterTools.showMapsInVP true
 
)catch()
gc()

I tried with format to string stream and execute it, but this didn't work :(

with extra include it look like it should work.

3dwannab's picture

You are my hero... I seen

You are my hero... I seen that string literal issue in the help, I wrote that in the 2nd post but maybe you missed that.

I never thought of writing it to a temp.ms file.. Fantastic work and help again my friend.

3dwannab's picture

From max help

Only spotting this now:
"This is a compile-time construct, therefore the file name specification must be a string literal, and not a variable or an expression."

This means that it has to be either:

include "C:\Program Files\Autodesk\3ds Max 2015\scripts\coronaConverter_v1.12.ms"

or

include "coronaConverter_v1.12.ms"

?????

What if this name changes is it possible by other methods to assign the filename like:

scripts = getfiles (srchDir + "\\" + "CoronaConverter_v1.ms")
include scripts

EDIT: Although this doesn't seem to work either. :[

pixamoon's picture

`

hey, try this:

scripts = getfiles (pathconfig.normalizepath(strDir + "\\CoronaConverter_v1*.ms"))

just add "*" before ".ms"

than you can do

if scripts.count > 0 then include scripts[1]

or last one (possibly newest one)

if scripts.count > 0 then include scripts[scripts.count]

Comment viewing options

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