isolate number from format string with quote ""

Hi all :)

They are the last details of my script (Environment Lighting HDR Studio (MR) ) but now I've a problem that I can not solve...

I want to enter parameters in rollut taking them from a txt file, but the info in file txt are written as Reflections (Subactive Color): (color 255 255 255) or Glossines: 8.0 ecc.. Now I know this form to isolate number from string array:

test = "Max Distance FallOff: 2.0"
strArr = filterString test " "
valuespinner = strArr[4] as float
print valuespinner

but I can not transfer ONLY values in rollout, because I always error of various kinds (!)
If I try with "openFile" and "readValue", (for read the file txt) I've always the result, for example, "scale()", but never specific value. I had no trouble writing values to and from .txt, but now I can not do this..

The question is very simple: How isolate a number from a string with quote "" and restore the values of spinner etc. the rollout reading a file .txt?

Any help is very important to me :D

Thanks
Michele71

Comments

Comment viewing options

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

Thanks for the stuff. it is

Thanks for the stuff. it is more like a gift for me to have such content as being fond of the codes.

Michele71's picture

Thanks barigazy for the link.

Thanks barigazy for the link.

My programming is really basic ( :D ) and anything that can increase the information and study is well accepted! I find Dotnet too difficult for me now...

Thanks for the help and valuable resources!!

Michele71's picture

Well, with the FN of Barigazy

Well, with the FN of Barigazy I've solved many parameters that work very well, while for the pickcolor, don't find solution. The suggestion of pixamoon

(color (strArr[i+2] as float) (strArr[i+3] as float) (strArr[i+4] as float))

does not work. With the fn I have always the result of 0.0...

I keep (work permitting) to seek solution :)

pixamoon's picture

ah

ah, because last value has ")" -> "127.5)"
you need to remove ")" and then convert to float

Michele71's picture

Heheheheh I have noticed of

Heheheheh I have noticed of this :D The problem is that then the development there is always something wrong... your advice anyway are very useful, I discovered things I did not know :) thanks!!!

pixamoon's picture

`

something like this: ?

(
	local csvFile = "C:\\renderpreview_0004.txt"
	local adata = (dotnetClass "System.IO.File").ReadAllLines csvFile
	local strArr = #()
 
	for i = 1 to adata.count do (
		pInfo = (filterString adata[i] " ")
		for o in pInfo do append strArr o
	)
 
	for i = 1 to strArr.count do (
		case strArr[i] of (
			"Reflection": ( if strArr[i+1] == "Color:" and strArr[i+2] == "(color" do RefColor = (color (strArr[i+3] as float) (strArr[i+4] as float) ((substring strArr[i+5] 1 (strArr[i+5].count-1)) as float)) )
		)
	)
)
 
print RefColor
Michele71's picture

WoW! thanks, now try it! :)

WoW! thanks, now try it! :)

pixamoon's picture

`

great :)
but this is starting to be complicated reading, maybe it will be better to format differently on save so you get: (with "|" quote)
name|value
or for color
name|value|value|value <- format "%|%|%|%" a.name a.color.red a.color.green a.color.blue
Than will be very easy to read single values

Michele71's picture

Hahahahah yes, you're right

Hahahahah yes, you're right :D
Unfortunately took an unexpected direction, I did not think of creating a command to reload for spinner, but I am learning a lot from this.

However your advice WORK and I am very happy, even if it is a bit "confusing" :)

Thanks a lot! really !!

pixamoon's picture

`

yes, me too. this was nice brain training :)

One more idea for saving settings is .ini file. But you know this probably.
It looks very easy with code:

setINISetting IniFIle "Settings" "glossines" (value as string)
getINISetting IniFile "Settings" "glossines"

I think I'll be using ini or xml :)
Best,

Comment viewing options

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