' RenamePortShortToLong.sbs ' Posted to SPSSX-List by Jon Peck on 2004/02/13 Option Explicit Sub Main 'BEGIN DESCRIPTION 'This script presumes that an Export command has written a correspondence table to 'a file in OMS XML format. It renames all variables with short names to the original long ones. 'END DESCRIPTION Dim theline As String Dim shortname As String, longname As String, startloc As Long, endloc As Long Dim shortlong As String On Error GoTo error_rename Const FILENAME ="c:\\temp\\exportnamelist.xml" ' change this as appropriate Const STARTPATTERN="Abbreviated ExtendedName Name " Const ENDPATTERN= "omsend." Const STARTLINE = "" Const ENDLINE = "" Open FILENAME For Input As #1 Line Input #1, theline startloc = InStr(theline, STARTPATTERN) If (startloc = 0) Then GoTo exit_rename End If theline = Mid(theline, startloc+ Len(STARTPATTERN)) Do endloc = InStr(theline, ENDLINE) shortlong = Mid(theline, Len(STARTLINE)+1, endloc - Len(STARTLINE)-1) 'short and long name' theline = Mid(theline, endloc + Len(ENDLINE)) shortname = Left(shortlong, InStr(shortlong, " ")) longname = Mid(shortlong, Len(shortname)+1) objSpssApp.ExecuteCommands("RENAME VARIABLES " & shortname & "=" & longname & ".", False) Loop Until Left(theline, Len(ENDPATTERN)) = ENDPATTERN exit_rename: Close #1 Exit Sub error_rename: MsgBox(Err.Description) GoTo exit_rename End Sub