Sign in to follow this  
Followers 0
Doxie

Readini, but only the first letter.

7 posts in this topic

Hi,

I use Readini to get some info, but the value is so long, i only need the first letter in the value, is that possible?

For example:

IniRead($sFile,"Software Inventory","MydocumentsPath","")

The value is:

C:\Documents and Settings\YPX5976\My Documents

or

D:\Documents and Settings\YPX5976\My Documents

or in sometimes

H:\Documents and Settings\YPX5976\My Documents

Can i make the iniread to get only the first so the value would be, C, D or H.

Thanks in advance


Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites



Read the whole value, then use StringLeft to extract the first letter.

Share this post


Link to post
Share on other sites

Thanks, it was so easy, but also so far away (for me) :idiot:


Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites

Another problem i got....

When i import data using Iniread and the value got a space in it, it does not import the space, instead it import " " without the ".

This is irretating, cause i import the data directly to excel sheet, and need to make calculations. But excel is not recognize the value as a number.

If i import 32 433 it looks like 32 433

(I can see that when i look in the excel built in script editor)

Is there anyway i can use iniread, to import just numbers???

Thanks in advance


Were ever i lay my script is my home...

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Well, Hmm..... put it into an array?

$i = IniRead ($file, $section, $key, $default)
stringsplit($i, " ")

If line = 32 433

$i[1] = 32

$i[2] = 433

You could then filewrite or send it

Filewrite($file, $i[1] & " " & $i[2])
; or you could send
WinActivate($window)
send($i[1] & " " & $i[2])

That's just a simple solution...I'm sure there's more complex ones out there.

Edit:Added "send"

Edited by Blue_Drache

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

StringStripWS() + Number()?

Share this post


Link to post
Share on other sites

Thanks for the fast reply, but i made the calculation in AutoIt, before i import it to excel. It works great.

$usedd = ($dsize-$dfree)
        If $usedd < $cfree Then
            $compa = ("Yes")
                Else
            $compa = ("No")
        EndIf

What i am doing is, it checks if the used space on D: is bigger then the free space on C:

We are about to migrate to XP, and one of our script does only work if it can create a image of D: on C:

Wich then means, it need enough space.


Were ever i lay my script is my home...

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