jeudi 28 septembre 2017

VBScript - How to scramble characters in a string?

I am writing a script that reads in a txt file. After the header lines, I read in the data lines. As each data line is read in, String values in columns AssetID and Description are to be scrambled. I split each line on tab delimiter. Knowing that AssetID is in array position 1, and Description is in position 2, I can get the strings.

I am new to VBScript, and I would like to know a simple way to scramble the two strings. Here is some code for reference. TIA!

P.S. for now I commented to the loop out so that I could test the "scrambling" on the first header line to make sure it works before I implement it on the entire project.

Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile("S:\PBS\G & A Non-Host\ELTP 28 Floor Experience\Resources and Links\AssetImport.txt", ForReading)
Set objFile2 = objFSO.CreateTextFile("S:\PBS\G & A Non-Host\ELTP 28 Floor Experience\Resources and Links\new.txt")

REM Do Until objFile.AtEndOfStream

    strLine = objFile.ReadLine

    arrFields = Split(strLine, vbTab)


    if (uBound(arrFields) = 1) then
        REM script to write header lines here
    Dim temp As String = RndStr
    objFile2.WriteLine arrFields(0)
    else
        REM scramble AssetID and Description Columns, then write

    end if

Wscript.echo arrFields(0)

REM Loop

objFile.Close
objFile2.Close




Aucun commentaire:

Enregistrer un commentaire