Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Usage
Register FAQ Calendar Today's Posts Search

Reply
 
Thread Tools Search this Thread Display Modes
Old 6th July 2012, 06:19   #1  |  Link
wiseant
Registered User
 
Join Date: May 2007
Posts: 146
writefile() problem inside Gscript

Hi

I can't seem to get writefile() to work for me, probably because I am using it inside a for loop in GScript.


chapters=12
inc=frames/(chapters)

for i=0 to chapters-1
t=Eval(String(inc*i))

I then do my convert frame to time
t0=(t/24)
# for 23.976:
tms = (t*1001)/24

t1=(t0/(60*60))
s1=String(t1)+":"
if (t1 < 10) {
s1 = "0"+s1
}
t2=(t0%(60*60)/60)
s2=String(t2) +":"
if (t2 < 10) {
s2 = "0"+s2
}
t3=(t0%60)
s3=String(t3)
t4 = tms - (t1*1000*60*60) - (t2*60*1000) - (t3*1000)
if (t4 > 499) {
t3=t3+1
s3=String(t3)
}
if (t3 < 10) {
s3 = "0"+s3
}
s5=s1+s2+s3

and end up with string s5

I then tried to writefile(filename, "s5")

and all I got was the same value, the last value, 12 times instead of all 12 values?

I tried writefile(filename, "i")
and got the same result

Any ideas?

TIA
wiseant is offline   Reply With Quote
Old 6th July 2012, 09:36   #2  |  Link
Gavino
Avisynth language lover
 
Join Date: Dec 2007
Location: Spain
Posts: 3,431
WriteFile is a runtime filter, so evaluates its expression(s) for every frame during the frame serving phase of Avisynth. At that stage, script variables will have their final values, so that's what gets written.

What you want to use instead here is WriteFileStart, which generates its output at compile-time, during script evaluation.

Incidentally, in your code:
Quote:
Originally Posted by wiseant View Post
for i=0 to chapters-1
t=Eval(String(inc*i))
Eval() is unnecessary and you can just write
t = inc*i

Also, I assume this is not a direct copy of your script as the correct syntax would be:
for (i=0, chapters-1) {
...
}
__________________
GScript and GRunT - complex Avisynth scripting made easier
Gavino is offline   Reply With Quote
Old 6th July 2012, 14:55   #3  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
It would look better (formatted), if you enclosed your code in CODE tags ('#' in advanced mode menu).

Also, assume you are enclosing GScript code appropriately

Code:
GScript("""  # Begin GScript code

# Your code.

""") # End Of GScript code
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???
StainlessS is offline   Reply With Quote
Old 6th July 2012, 20:39   #4  |  Link
wiseant
Registered User
 
Join Date: May 2007
Posts: 146
Gavino:

Yes - I only posted some of the code . . . and thanks for the tip re t = inc*i

I used

WriteFileStart(filename,"s5", append=true)

works like a charm - Thanks Gavino

Output:
00:00
09:32
19:03
28:35
38:07
47:38
57:10
01:06:42
01:16:13
01:25:45
01:35:17
01:44:48

Stainless:
Thanks for the tip - I'll have to look into using CODE tags
wiseant is offline   Reply With Quote
Old 7th July 2012, 00:08   #5  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
If you just want to use the code tags directly without going into advance mode (forum)
then use as start tag $CODE% and end tag $/CODE%

but replacing the '$' chars with '[' and end '%' chars with ']',
I dont know how to ESCAPE them without the forum thing altering them.

EDIT: Ie, removing '*' from below

[*CODE] your formatted stuff [*/CODE]
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 7th July 2012 at 00:18.
StainlessS is offline   Reply With Quote
Old 7th July 2012, 02:24   #6  |  Link
-Vit-
Registered User
 
Join Date: Jul 2010
Posts: 448
StainlessS: Going a little OT, but you can write tags without them being parsed by enclosing in a [NOPARSE] tag.

The line below is wrapped in NOPARSE:
[CODE]Testy[/CODE]
-Vit- is offline   Reply With Quote
Old 7th July 2012, 02:30   #7  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Thankyou fine sir for the education, not over the top at all, some of us
need that little extra bit of help from you educators of men.

Really, thankyou.

EDIT: Although NOCODE might have been more obvious, not your fault and
I do not blame you at all for it. (Well maybe just a bit).
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 7th July 2012 at 02:42.
StainlessS is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 22:34.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.