View Full Version : VDM Scripting confusion???
Tuning
30th January 2004, 14:56
Just tried scrpting with VDM...
For eg:
VirtualDub.Open( "D:\temp\THX.avi",0,0);
VirtualDub.subset.Delete();
VirtualDub.Close();
If I use this script, and load the *.vcf through command line, an error is shown as no file is found....even if the file in reality exists!
Again if I change script like this:VirtualDub.Open( "D:\\temp\\THX.avi",0,0);
VirtualDub.subset.Delete();
VirtualDub.Close();
It works. :confused:
So does this implies every script need to have "//" instead of single.
the input file part in script is a string generated according to file opened in my application...
Thanks.
fccHandler
31st January 2004, 19:06
Yes, it uses a C convention in which "\" is always treated as the first character of an escape code, used to allow un-typeable characters in a string. For instance, "\n" = (new line), "\t" = (tab), "\0" = (null character), and so on.
"\\" is the escape code for "\". ;)
Leak
31st January 2004, 19:30
Originally posted by fccHandler
Yes, it uses a C convention in which "\" is always treated as the first character of an escape code, used to allow un-typeable characters in a string. For instance, "\n" = (new line), "\t" = (tab), "\0" = (null character), and so on.
"\\" is the escape code for "\". ;)
Well, if you don't want to escape your backslashes you can always replace them with forward slashes, i.e. "C:/foo/bar/baz.avi"... :)
np: Static/Valerie Trebeljahr - Turn On Switch Off (Flavour Has No Name)
Tuning
1st February 2004, 03:48
Thanks fcchandler and Leak. But here I could not replace the slashes as in c convention. That is, I use VB.net or Delphi's open/save file dialog to save the input/output filename as a string. Then in script the input and output are replaced at runtime. Then a text file writing is done to generate vcf file.
So if this is true, then my idea is not gonna work.:(
Is there a better way integrating input/output in VDM script or job file? Or Is the comments that is to be replaced. Developers, how is this done generally?
Any comments are appreciated. :)
Thanks:rolleyes:
fccHandler
1st February 2004, 06:45
Why can't you simply modify the string(s) before writing them into the .vcf file, replacing each "\" with "\\" (or "/", as Leak suggests)?
I really don't understand what the problem is. Perhaps it would make more sense if you posted your VB code. (Sorry to say, I'm not familiar with Delphi...)
Tuning
1st February 2004, 10:38
Why can't you simply modify the string(s) before writing them into the .vcf file, replacing each "\" with "\\" (or "/", as Leak suggests)?
Reason is simple, I don't know how to code a function that searches and replaces "/" with "//" making it more complex than now. So I thought there may be some simple method than coding this. If there is no other way then I'm on to it.:mad:. :D
PS: Its the initial stage of my app and code pasting will be childish.
:o , so....
fccHandler
1st February 2004, 17:26
This will work in VB:
x = 1
Do While x <= Len(filename$)
If Mid$(filename$, x, 1) = "\" Then
filename$ = Left$(filename$, x) & "\" & Right$(filename$, Len(filename$) - x)
x = x + 1
End If
x = x + 1
Loop
Tuning
2nd February 2004, 04:03
AHA!, Thanks Fcchandler.
stax76
2nd February 2004, 05:24
in .NET there are various possibilities to dublicate a character, here the ones I remember:
'replace method of the string class
Dim s1 As String = "C:\tes\t.txt".Replace("\", "\\")
'legacy crap
Dim s2 As String = Microsoft.VisualBasic.Replace("C:\tes\t.txt", "\", "\\")
'regular expressions, learn it now!
Dim s3 As String = System.Text.RegularExpressions.Regex.Replace("C:\tes\t.txt", "\\", "\\")
'StringBuilder has performance advantages
Dim s4 As String = New System.Text.StringBuilder("C:\tes\t.txt").Replace("\", "\\").ToString()
'for each works with a string because the string class implements the IEnumerable interface
Dim s5 As String
For Each i As String In "C:\tes\t.txt"
s5 += i
If i = "\" Then
s5 += "\"
End If
Next
fccHandler
2nd February 2004, 16:18
Good call by Dolemite! I forgot about the Replace() function. :D
Tuning
3rd February 2004, 09:41
Thanks Dolemite! :) . Your method is very easy. I will try it next.
Btw, i did it in my own way, created a VC++ dll with this code. I can now use it for any app that uses Vdub/VDM.
struct string stringformat(struct string input)
{
struct string temp1;
for(int i=0,j=0;i<100,j<100;i++,j++)
{
if(input.a[i]==char(92))
{
temp1.a[j]=char(92);
temp1.a[++j]=char(92);//ASCII Code for backslash
}
else
temp1.a[j]=input.a[i];
}
return temp1;
}
Thanks for all of the comments. I must learn more patiently.:p
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.