Page 1 of 1 1
Topic Options
#189554 - 2008-09-09 05:27 PM Help converting .vbs to .kix
matthill Offline
Fresh Scripter

Registered: 2008-03-12
Posts: 9
Need assistance converting a vbs script to kix.

Here's the script:

Dim objFSO
Dim objTextFile
Dim containsSettings
Dim strMiniRecIniLocation
strMiniRecIniLocation = "C:\Program Files\minirec\record.ini"

Set objFSO = CreateObject("Scripting.FileSystemObject")

If objFSO.FileExists(strMiniRecIniLocation) Then
Set objTextFile = objFSO.OpenTextFile(strMiniRecIniLocation,1)

containsSettings = 0
Do until objTextFile.AtEndOfStream
strLine = objTextFile.ReadLine
If containsSettings = 0 Then
containsSettings = InStr(1, strLine, "[ExtTools]", 1)
End If
Loop

objTextFile.Close

If containsSettings = 0 Then
Set objTextFile = objFSO.OpenTextFile(strMiniRecIniLocation,8)
objTextFile.WriteLine ""
objTextFile.WriteLine "[ExtTools]"
objTextFile.WriteLine "ArchivalProgram=C:\ImportApp\OnBaseImportApp.exe"
objTextFile.WriteLine "ArchivalProgramParams=-docTypeID=125 -docTypeGrpID=101"
objTextFile.Close
End If

Set objTextFile = Nothing
Else
MsgBox("Can't find minirec config file at " & strMiniRecIniLocation)
End If

Set objFSO = Nothing




Thanks

Top
#189556 - 2008-09-09 07:24 PM Re: Help converting .vbs to .kix [Re: matthill]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
First, did you take a stab at it? What results did you get? It looks like you are just trying to edit a text file. Have you tried the native kix readline or readprofilestring (and corresponding writes)?
Top
#189557 - 2008-09-09 07:34 PM Re: Help converting .vbs to .kix [Re: BradV]
matthill Offline
Fresh Scripter

Registered: 2008-03-12
Posts: 9
I didn't even bother with it.
I don't know kix or vbs well enough.

Top
#189558 - 2008-09-09 07:48 PM Re: Help converting .vbs to .kix [Re: matthill]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
Well COM is a great tool, but it has a lot of overhead. It looks like you are trying to do something very simple. If that is the case, you'd be better off writing directly in kix. How are you going to learn if you don't try? \:\)
Top
#189560 - 2008-09-09 09:21 PM Re: Help converting .vbs to .kix [Re: BradV]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
heh.
that's so simple in kix...

 Code:
$theFile="C:\Program Files\minirec\record.ini"
if exist($theFile)
  if ""=readprofilestring($theFile,"ExtTools","")
    $=writeprofilestring($theFile,"ExtTools","ArchivalProgram","C:\ImportApp\OnBaseImportApp.exe")
    $=writeprofilestring($theFile,"ExtTools","ArchivalProgramParams","-docTypeID=125 -docTypeGrpID=101")
  endif
else
  $=MessageBox("Can't find minirec config file at " + $theFile)
endif


NOTE!
I did write this code in quick reply and it hasn't been checked for errors.
at least the messagebox code is not right, so check the syntax for it and fix it.
I am too lazy to do that.
_________________________
!

download KiXnet

Top
#189600 - 2008-09-10 11:48 PM Re: Help converting .vbs to .kix [Re: Lonkero]
matthill Offline
Fresh Scripter

Registered: 2008-03-12
Posts: 9
Thanks. I'll give it a try.
Top
#189667 - 2008-09-15 11:24 AM Re: Help converting .vbs to .kix [Re: matthill]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
And here for the actual translation just because I felt like it
 Code:
Dim $objFSO
Dim $objTextFile
Dim $containsSettings
Dim $strMiniRecIniLocation 
$strMiniRecIniLocation = "C:\Program Files\minirec\record.ini"

$objFSO = CreateObject("Scripting.FileSystemObject")

If $objFSO.FileExists($strMiniRecIniLocation)
  $objTextFile = $objFSO.OpenTextFile($strMiniRecIniLocation,1)
  $containsSettings = 0
  Do Until $objTextFile.AtEndOfStream
    $strLine = $objTextFile.ReadLine
    If $containsSettings = 0
      $containsSettings = InStr($strLine, "[ExtTools]")
    EndIf
  Loop
  $objTextFile.Close

  If $containsSettings = 0
    $objTextFile = $objFSO.OpenTextFile($strMiniRecIniLocation,8)
    $objTextFile.WriteLine("")
    $objTextFile.WriteLine("[ExtTools]")
    $objTextFile.WriteLine("ArchivalProgram=C:\ImportApp\OnBaseImportApp.exe")
    $objTextFile.WriteLine("ArchivalProgramParams=-docTypeID=125 -docTypeGrpID=101")
    $objTextFile.Close
  EndIf

  $objTextFile = ""
Else
  $=MessageBox("Can't find minirec config file at " + $strMiniRecIniLocation,"Info")
EndIf

$objFSO = ""

Top
#189679 - 2008-09-15 10:36 PM Re: Help converting .vbs to .kix [Re: Arend_]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
uhm...
you didn't use any native stuff?
lol. sure that works too and is "exact translation"

_________________________
!

download KiXnet

Top
#189710 - 2008-09-17 01:44 PM Re: Help converting .vbs to .kix [Re: Lonkero]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
I did the "exact" translation because then ppl who read this know what the differences are exactly between kix and vbs, and then take a look at your translation to see that kix is much easier and betetr to learn in the first place \:\)
Top
#189725 - 2008-09-17 05:09 PM Re: Help converting .vbs to .kix [Re: Arend_]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
I'd be interested if matthill tries both a native kix version and the COM version apronk came up with and would report speed differences.
Top
#189726 - 2008-09-17 10:56 PM Re: Help converting .vbs to .kix [Re: BradV]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
bradv, it's enermous but doesn't really matter on logic that runs only ones.
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 405 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.063 seconds in which 0.027 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org