Jump to content

VBS multi part writeline vs. FileWriteLine


Recommended Posts

Suppose you had this code

OStream.WriteLine Valname & Val1 & ",1,\": OStream.WriteLine "  " & Right(cLine, Len(cLine) - vP - 7): vCk = 1

where

Valname = "ImagePath"
Val1 = "=hex:"
cLine = ""ImagePath"=hex:73,00,79,00,73,00,74,00,65,00,6d,00,33,00,32,00,5c,00,44,00,\"
vP = 11

The file being read is a .reg file. The above vbs line writes the line in a certain format. However, because this is a hex value and there is a "\", the hex value continues on following lines. I have not used the ":" like that before, but it appears to keep writing lines until the end of the hex value is reached, then it assigns vCk = 1. All without moving around in the loop that reads the file.

Is there anything similar for AutoIt? I realize I can work through the file one line at a time with clever coding. But that is a pretty nifty feature vbs has there if it is doing what I think it is doing.

Any thoughts?

Sul

Link to comment
Share on other sites

Hi,

I think there is nothing special about the ":" - it could have been written on separate lines.

Post the script and then someone will probably convert it ...

[put a "wscript.echo" inside the loop to check how often it loops etc...]

Best, randall

Link to comment
Share on other sites

Pretty much what you see in the top piece of code is what the line says. There is some logic before it, If Else type stuff to test for different StingInStr values. But, once it gets to that poing, it seems to be doing 3 things. Especially the last one, setting a vairable = 1. The only way I have ever seen that done on the same line would be in something like batch. I have not seen that in VBS.

Anyway, I finally decided to just build a longer loop.

But for future reference it would be nice to know what that does. When you have to use vbs for something, anything to speed it up helps :P

Later,

Sul

Link to comment
Share on other sites

OStream.WriteLine Valname & Val1 & ",1,\"
OStream.WriteLine "  " & Right(cLine, Len(cLine) - vP - 7)
vCk = 1

FileWriteLine($file, $Valname & $Val1 & ",1,\")
FileWriteLine($file, "  " & StringRight($cLine, StringLen($cLine) - $vP - 7)
$vCk = 1

Nothing special to the VBS code you show, Sul. It is rather ordinary code which has been added on to one line which VBS allows more then one command per line by using semicolons to separate them. The Stream object is what VBS uses for writing files as compared to AutoIt's writing functions.

To be honest, the use of semicolon's in the VBS was abused to make poorly readable code. It is fine for the simpler items like very small loops etc.

Link to comment
Share on other sites

I see. I don't think then that it did what I thought it was going to do. The logic threw me because I thought it was some kind of a special looping command. But as it turns out, the vb code snippet I was using, it just stopped the line there, although the next line should have been concated. I did not think the author would do that, but he did.

I made it mo' better now :P

Sul

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...