Sign in to follow this  
Followers 0
jinbaba

Copying substring from a String

2 posts in this topic

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.

Regards,

JinBaba

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)

1 person likes this

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  
Followers 0