Sign in to follow this  
Followers 0
Blue_Drache

String Manipulation

6 posts in this topic

Ok, here's the meat of the code:

; Simple ditty for input of DCN conversion to Mobius Number.

DIM $dcn
DIM $i

WinActivate("DocumentDirect -")

DO
    send("^{TAB}")
UNTIL WinActive("DocumentDirect - [Document Explorer]")

    Sleep(500)
    AutoItSetOption("SendKeyDelay",300)
    send("{ALTDOWN}FLM{ALTUP}")
    
WinWaitActive("Locate")

; Get the DCN from the user.

DO
    $dcn = InputBox("DCN Entry", "Please enter the 12 digit DCN.", "123456789012", "", -1, -1, 0, 0)
    if @error = 1 then
        Exit
    endif

    $test1 = stringlen($dcn)
    $test2 = stringisdigit($dcn)

    if $test1 <> 12 OR $test2 <> 1 then
        MsgBox(48, "ERROR", "Please input a 12 digit DCN with no alpha characters please.")
    endif

UNTIL $test1 = 12 AND $test2 = 1

; String manipulation starts here

$digits = stringsplit($dcn,"")
$digits[1] = 0

; Input loop for each individual digit

$i = 1

Do
    WinActivate("Locate")
    AutoItSetOption("SendKeyDelay",5)
    send($digits[$i])
    $i = $i + 1
        if $i = 5 then
            $i = 6
        endif
Until $i = 12

WinActivate("Locate")
    send("!O")
    
; End of File

Just change the "Locate" and "DocumentDirect" windows to something like "Notepad" and "Untitled -". For your tests, any non-alpha 12 digit number will work as I have to have the first number a 0, and drop the fifth and last numbers entirely. It works as is, but is a little slow. I was wondering if there's a better way than the loop I currently have.

The sleep delay and the keystroke delay at the head of the program is there for a reason. The program I'm using it for is a little slow on its toes when it comes to the alt-characters and AutoIt's automation.

The DO loop sending control tab is not required for testing. I just sent the whole program for reference.


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

Share this post


Link to post
Share on other sites



Wow. 25 views. No assistance. :idiot:

Any ideas, thoughts, or other insights would be most welcome!

:D


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

Share this post


Link to post
Share on other sites

You didn't make very clear the main function of the script. I looked over the script again, and I still cannot figure out what effect you are trying to achieve. Please explain clearly and succinctly what the problem is and what you are trying to do.


Who else would I be?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Not sure what you are doing, but here is one way to do this part:

; Input loop for each individual digit

AutoItSetOption("SendKeyDelay",5); only need to do it once, not in every loop
For $i= 1 to 12
       if $i = 5 then $i = 6
   WinActivate("Locate"); I guess you want to keep it activated
   send($digits[$i])
next

What I don't understand exactly is why you go through all the trouble of making it into a array?

Let me see, you replace whatever is the first digit with 0 and you just skip the 5th digit completely. Seems funny, but you could do it with:

$dcn=StringLeft("0" & Stringtrimleft($dcn,1),4) & Stringright($dcn,7)
AutoItSetOption("SendKeyDelay",5)
WinActivate("Locate")
send($dcn)
Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

You didn't make very clear the main function of the script. I looked over the script again, and I still cannot figure out what effect you are trying to achieve. Please explain clearly and succinctly what the problem is and what you are trying to do.

<{POST_SNAPBACK}>

The script is for automatic entry of a number based off another one. I work in a data entry processing center for an insurance company. Electronic claims are filed in our system under two separate code numbers. The main number is filed with 12 digits and 1 trailing alpha. The secondary number in our database vault is based off of the main number but only contains 10 digits.

Example: Main number - 123456789012v

Data number - 0234678901

I'm trying to get this script to simplify a very repetitive task that over 200 people in this office do at least 25 to 50 times a day each. If it works, we can save (albeit small ammounts of) time on each person (but it adds up cumulatively).

I'm also trying to justify the use of this program for other tasks. Right now, it's more or less a "toy" in the eyes of management as they prefer huge...hulking programs made in VB (which I don't have any idea how to code in).


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

Share this post


Link to post
Share on other sites

What I don't understand exactly is why you go through all the trouble of making it into a array?

I did it as an array because that's the first solution that came to me. :idiot: Didn't know how else to do it. It was a brute force solution, and it worked. I'd thought about using the StringLeft/Right but wasn't clear on how to use it. The ampersands are what throw me off.

Let me see, you replace whatever is the first digit with 0 and you just skip the 5th digit completely. Seems funny, but you could do it with:

$dcn=StringLeft("0" & Stringtrimleft($dcn,1),4) & Stringright($dcn,7)
AutoItSetOption("SendKeyDelay",5)
WinActivate("Locate")
send($dcn)

<{POST_SNAPBACK}>

Ok, it worked...I just had to add an additional Stringtrimright($dcn,1) after the process you gave me. It works much better now. Thank you for your help.

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

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