Jump to content

Word groups


Codemike
 Share

Recommended Posts

CodeMike,

This is what I understand from your post. You have items:

bread, limodade, cake, limodade

And you want to associate prices with each item. Somehow clipget() is involved with the prices. You also want to detect duplicate items.

Questions:

- where do each of these data elements come from (gui, file, db, etc)?

- what do you want to do with them?

It is easy enough to detect duplicates.

What you should do:

Answer the two questions above, write some code, follow-up with questions resulting from code or design issues.

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

CodeMike,

This is what I understand from your post. You have items:

bread, limodade, cake, limodade

And you want to associate prices with each item. Somehow clipget() is involved with the prices. You also want to detect duplicate items.

Questions:

- where do each of these data elements come from (gui, file, db, etc)?

- what do you want to do with them?

It is easy enough to detect duplicates.

What you should do:

Answer the two questions above, write some code, follow-up with questions resulting from code or design issues.

kylomas

This is some vb.net example. Can AutoIt do something like?

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim prices = New Dictionary(Of String, Decimal)()

Dim rows = Clipboard.GetText().Split(ControlChars.NewLine)

For Each row In rows

If (Not String.IsNullOrWhiteSpace(row)) Then

Dim information = row.Split(ControlChars.Tab)

Dim Sum As Decimal

If information.Length <> 3 OrElse information(2) <> "dollars" OrElse Decimal.TryParse(information(1), Sum) Then

MessageBox.Show("Row's information wrong form: " & row)

ElseIf prices.ContainsKey(information(0)) Then

MessageBox.Show("product " + information(0) + " is many times, only first notice")

Else

prices.Add(information(0), Sum)

End If

End If

Next

End Sub

End Class

Link to comment
Share on other sites

CodeMike,

I do NOT know vb.net but am able to glean the following:

- the code is splitting clip-board data on "tab" characters

- there is some kind of dictionary look-up ocurring (unclear where the dict data is comming from, possibly some DB as

do NOT understand the first line of the code)

- there is something called "TryParse"...don't know if it is vb.net or a function that is not shown

- after some editing results are either echoed to the user or a dict entry is added

Net out, yes this can be done in AutoIT, need more info (especially code) to arrive at a solution

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

CodeMike,

To answer your question specific to duplicates...

The following code will work on alphameric data. The routine could be turned into a function within other code.

;
;
;  clipboard contains "john sue mary    alex    john" as tab seperated values
;
;

#include<array.au3>

$str = stringsplit(clipget(),@tab)

_arraysort($str)

for $i = 0 to ubound($str)  - 1
    if $i = 0 then ContinueLoop
    if $str[$i] = $str[$i-1] then consolewrite('Dup found at elements ' & $i-1 & ' ' & $i & '  value = ' & $str[$i] & @lf)
Next

Good Luck,

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...