Jump to content
Sign in to follow this  

Copying substring from a String

Recommended Posts


Hello Folks,

I want to copy a substring from a string. Since autoit strings are not like C strings. I am unable to copy a portion of string to new string.

I want to extract file size from a torrent file. And I want torrent file to be unchanged.

Here is how I tried

; Fille size
$fh = FileOpen("C:\Documents and Settings\User\My Documents\torrents\file.torrent", 0)
$contents = FileRead($fh)
; File size is mentioned after keyword 'length'
$startI = StringInStr($contents, "lengthi")
$endI = StringInStr($contents, ":", 1, 1, $startI)
; I want to copy string between startI and endI to a new string. How to do that?

Your help required.



Share this post

Link to post
Share on other sites

$content = FileRead('C:\Documents and Settings\User\My Documents\torrents\file.torrent')
$start = StringInStr($content, 'length')
$end = StringInStr($content, ':', 0, 1, $start)
$size = StringMid($content, $start, $end - $start)

  • Like 1

Share this post

Link to post
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

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.