Jump to content
Sign in to follow this  
Command3r

[Resolved]Help me completing this script

Recommended Posts

Hello, i'm making this tool to convert "English" letters To "Arabic" letters

but i have some problems in reading "input1"

Notice: it isn't translator!!

here's the script:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>

$Form1 = GUICreate("Form1", 257, 155, 339, 282)
$Input1 = GUICtrlCreateInput("", 32, 32, 201, 21)
$Input2 = GUICtrlCreateInput("", 32, 88, 201, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_RIGHT))
$Label1 = GUICtrlCreateLabel("English", 104, 8, 38, 17)
$Button1 = GUICtrlCreateButton("Ta7weel", 96, 120, 75, 25)
$Label2 = GUICtrlCreateLabel("Franco", 104, 64, 37, 17)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Button1
Local $Read1 = GUICtrlRead($Input1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
If StringInStr($Read1, "3") Then
_GUICtrlEdit_AppendText($Input2, "ع")
EndIf
If StringInStr($Read1, "3'") Then
_GUICtrlEdit_AppendText($Input2, "غ")
EndIf
If StringInStr($Read1, "5") Then
_GUICtrlEdit_AppendText($Input2, "خ")
EndIf
If StringInStr($Read1, "7") Then
_GUICtrlEdit_AppendText($Input2, "ح")
EndIf
If StringInStr($Read1, "9") Then
_GUICtrlEdit_AppendText($Input2, "ص")
EndIf
If StringInStr($Read1, "a") Then
_GUICtrlEdit_AppendText($Input2, "ا")
EndIf
If StringInStr($Read1, "b") Then
_GUICtrlEdit_AppendText($Input2, "ب")
EndIf
If StringInStr($Read1, "c") Then
_GUICtrlEdit_AppendText($Input2, "س")
EndIf
If StringInStr($Read1, "d") Then
_GUICtrlEdit_AppendText($Input2, "د")
EndIf
If StringInStr($Read1, "e") Then
_GUICtrlEdit_AppendText($Input2, "ي")
EndIf
If StringInStr($Read1, "f") Then
_GUICtrlEdit_AppendText($Input2, "ف")
EndIf
If StringInStr($Read1, "g") Then
_GUICtrlEdit_AppendText($Input2, "ج")
EndIf
If StringInStr($Read1, "h") Then
_GUICtrlEdit_AppendText($Input2, "ه")
EndIf
If StringInStr($Read1, "i") Then
_GUICtrlEdit_AppendText($Input2, "ي")
EndIf
If StringInStr($Read1, "j") Then
_GUICtrlEdit_AppendText($Input2, "ج")
EndIf
If StringInStr($Read1, "k") Then
_GUICtrlEdit_AppendText($Input2, "ك")
EndIf
If StringInStr($Read1, "l") Then
_GUICtrlEdit_AppendText($Input2, "ل")
EndIf
If StringInStr($Read1, "m") Then
_GUICtrlEdit_AppendText($Input2, "م")
EndIf
If StringInStr($Read1, "n") Then
_GUICtrlEdit_AppendText($Input2, "ن")
EndIf
If StringInStr($Read1, "o") Then
_GUICtrlEdit_AppendText($Input2, "و")
EndIf
If StringInStr($Read1, "p") Then
_GUICtrlEdit_AppendText($Input2, "ب")
EndIf
If StringInStr($Read1, "q") Then
_GUICtrlEdit_AppendText($Input2, "ق")
EndIf
If StringInStr($Read1, "r") Then
_GUICtrlEdit_AppendText($Input2, "ر")
EndIf
If StringInStr($Read1, "s") Then
_GUICtrlEdit_AppendText($Input2, "س")
EndIf
If StringInStr($Read1, "t") Then
_GUICtrlEdit_AppendText($Input2, "ت")
EndIf
If StringInStr($Read1, "u") Then
_GUICtrlEdit_AppendText($Input2, "و")
EndIf
If StringInStr($Read1, "v") Then
_GUICtrlEdit_AppendText($Input2, "ف")
EndIf
If StringInStr($Read1, "w") Then
_GUICtrlEdit_AppendText($Input2, "و")
EndIf
If StringInStr($Read1, "x") Then
_GUICtrlEdit_AppendText($Input2, "ق")
EndIf
If StringInStr($Read1, "y") Then
_GUICtrlEdit_AppendText($Input2, "ي")
EndIf
If StringInStr($Read1, "z") Then
_GUICtrlEdit_AppendText($Input2, "ز")
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EndSwitch
WEnd

the script working well. but the problem is arranging the output letters

e.g.

i want convert this word "fas"... it must be "فاس" but it converted to "افس".

problem reason: autoit has read "A" letter before "F" & "S" so output will be arranged as reading.

what i need: convert and arragne "Arabic" letters wherever it is as "English" letters. !!

e.g.

A= 1

B= 2

C= 3

D=4

Text what will be converted: "CBDA" so it must be convert like that "3241" but in the script above it converting like that "123".

sorry for bad english :)

and thanks for help ;)

Resolved:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
Local $Form1 = GUICreate("Form1", 257, 155, 339, 282)
Local $Input1 = GUICtrlCreateInput("", 32, 32, 201, 21)
Local $Input2 = GUICtrlCreateInput("", 32, 88, 201, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_RIGHT))
Local $Label1 = GUICtrlCreateLabel("English", 104, 8, 38, 17)
Local $Button1 = GUICtrlCreateButton("Ta7weel", 96, 120, 75, 25)
Local $Label2 = GUICtrlCreateLabel("Franco", 104, 64, 37, 17)
GUISetState(@SW_SHOW)
Local $Read1, $Read2
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button1
   $Read1 = StringSplit(GUICtrlRead($Input1), '', 2)
   $Read2 = ''
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   For $char In $Read1
    Switch $char
     Case 'a'
      $Read2 &= '1'
     Case 'b'
      $Read2 &= '2'
     Case 'c'
      $Read2 &= '3'
     Case 'd'
      $Read2 &= '4'
     Case 'e'
      $Read2 &= '5'
     ; insert as many Case statements as possible input characters
     Case Else
      $Read2 &= '?'
    EndSwitch
   Next
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   GUICtrlSetData($Input2, $Read2)  ; write new data all at once
EndSwitch
WEnd

Edit: resolved Edited by Command3r

[font="arial, helvetica, sans-serif;"]Advice for you[/font][font="arial, helvetica, sans-serif;"]: [/font][u]Search[/u] before posting.

 

[font="arial, helvetica, sans-serif;"] *********** Problem solved? if yes [/font][color=rgb(0,0,0);font-family:arial, helvetica, sans-serif;] *********[/color]

[font="arial, helvetica, sans-serif;"]******* press "Mark Solved" button. *******[/font]

Share this post


Link to post
Share on other sites

The actual issue is with the sequence of If... Append that _you_ coded.

To make simple code work the way you want, you can first use StringSplit to obtain an array of successive english characters, then loop on this array and convert each character in turn into their arabic counterpart. That would work as you intend it to work.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

i can't do it but i'll try

ُ

Edit: i dont know more about array and StringSplit

may you write simple script explaining?

Edited by Command3r

[font="arial, helvetica, sans-serif;"]Advice for you[/font][font="arial, helvetica, sans-serif;"]: [/font][u]Search[/u] before posting.

 

[font="arial, helvetica, sans-serif;"] *********** Problem solved? if yes [/font][color=rgb(0,0,0);font-family:arial, helvetica, sans-serif;] *********[/color]

[font="arial, helvetica, sans-serif;"]******* press "Mark Solved" button. *******[/font]

Share this post


Link to post
Share on other sites

this isn't working

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>

$Form1 = GUICreate("Form1", 257, 155, 339, 282)
$Input1 = GUICtrlCreateInput("", 32, 32, 201, 21)
$Input2 = GUICtrlCreateInput("", 32, 88, 201, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_RIGHT))
$Label1 = GUICtrlCreateLabel("English", 104, 8, 38, 17)
$Button1 = GUICtrlCreateButton("Ta7weel", 96, 120, 75, 25)
$Label2 = GUICtrlCreateLabel("Franco", 104, 64, 37, 17)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Button1
Local $Read1 = GUICtrlRead($Input1)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
If StringSplit($Read1, "a") Then
_GUICtrlEdit_AppendText($Input2, "1")
EndIf
If StringSplit($Read1, "b") Then
_GUICtrlEdit_AppendText($Input2, "2")
EndIf
If StringSplit($Read1, "c") Then
_GUICtrlEdit_AppendText($Input2, "3")
EndIf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
EndSwitch
WEnd

Edit: Editing script

Edited by Command3r

[font="arial, helvetica, sans-serif;"]Advice for you[/font][font="arial, helvetica, sans-serif;"]: [/font][u]Search[/u] before posting.

 

[font="arial, helvetica, sans-serif;"] *********** Problem solved? if yes [/font][color=rgb(0,0,0);font-family:arial, helvetica, sans-serif;] *********[/color]

[font="arial, helvetica, sans-serif;"]******* press "Mark Solved" button. *******[/font]

Share this post


Link to post
Share on other sites

Try this:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
Local $Form1 = GUICreate("Form1", 257, 155, 339, 282)
Local $Input1 = GUICtrlCreateInput("", 32, 32, 201, 21)
Local $Input2 = GUICtrlCreateInput("", 32, 88, 201, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_RIGHT))
Local $Label1 = GUICtrlCreateLabel("English", 104, 8, 38, 17)
Local $Button1 = GUICtrlCreateButton("Ta7weel", 96, 120, 75, 25)
Local $Label2 = GUICtrlCreateLabel("Franco", 104, 64, 37, 17)
GUISetState(@SW_SHOW)
Local $Read1, $Read2
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button1
   $Read1 = StringSplit(GUICtrlRead($Input1), '', 2)
   $Read2 = ''
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   For $char In $Read1
    Switch $char
     Case 'a'
      $Read2 &= '1'
     Case 'b'
      $Read2 &= '2'
     Case 'c'
      $Read2 &= '3'
     Case 'd'
      $Read2 &= '4'
     Case 'e'
      $Read2 &= '5'
     ; insert as many Case statements as possible input characters
     Case Else
      $Read2 &= '?'
    EndSwitch
   Next
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   GUICtrlSetData($Input2, $Read2)  ; write new data all at once
EndSwitch
WEnd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

jchd,

Nice. I had something like this in mind...

#include <ButtonConstants.au3>
#include <array.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

;translation table $a_xlate)
;
;           col0          col1
;        (english    (something =
;         letter)     to english letter)
;   row0    a              a-x
;   row1    b              b-x
;   row2    c              c-x
;   row3    d              d-x
;   row4    e              e-x
;   row5    f              f-x
;
;   ... and so on for all symbols (letters) to be transposed (translated)
;

Local $a_xlate[31][2]

$a_xlate[00][0] = 'a'
$a_xlate[00][1] = 'a-x'
$a_xlate[01][0] = 'b'
$a_xlate[01][1] = 'b-x'
$a_xlate[02][0] = 'c'
$a_xlate[02][1] = 'c-x'
$a_xlate[03][0] = 'd'
$a_xlate[03][1] = 'd-x'
$a_xlate[04][0] = 'e'
$a_xlate[04][1] = 'e-x'
$a_xlate[05][0] = 'f'
$a_xlate[05][1] = 'f-x'
$a_xlate[06][0] = 'g'
$a_xlate[06][1] = 'g-x'
$a_xlate[07][0] = 'h'
$a_xlate[07][1] = 'h-x'
$a_xlate[08][0] = 'i'
$a_xlate[08][1] = 'i-x'
$a_xlate[09][0] = 'j'
$a_xlate[09][1] = 'j-x'
$a_xlate[10][0] = 'k'
$a_xlate[10][1] = 'k-x'
$a_xlate[11][0] = 'l'
$a_xlate[11][1] = 'l-x'
$a_xlate[12][0] = 'm'
$a_xlate[12][1] = 'm-x'
$a_xlate[13][0] = 'n'
$a_xlate[13][1] = 'n-x'
$a_xlate[14][0] = 'o'
$a_xlate[14][1] = 'o-x'
$a_xlate[15][0] = 'p'
$a_xlate[15][1] = 'p-x'
$a_xlate[16][0] = 'q'
$a_xlate[16][1] = 'q-x'
$a_xlate[17][0] = 'r'
$a_xlate[17][1] = 'r-x'
$a_xlate[18][0] = 's'
$a_xlate[18][1] = 's-x'
$a_xlate[19][0] = 't'
$a_xlate[19][1] = 't-x'
$a_xlate[20][0] = 'u'
$a_xlate[20][1] = 'u-x'
$a_xlate[21][0] = 'v'
$a_xlate[21][1] = 'v-x'
$a_xlate[22][0] = 'w'
$a_xlate[22][1] = 'w-x'
$a_xlate[23][0] = 'x'
$a_xlate[23][1] = 'x-x'
$a_xlate[24][0] = 'y'
$a_xlate[24][1] = 'y-x'
$a_xlate[25][0] = 'z'
$a_xlate[25][1] = 'z-x'
$a_xlate[26][0] = '1'
$a_xlate[26][1] = '1-x'
$a_xlate[27][0] = '2'
$a_xlate[27][1] = '2-x'
$a_xlate[28][0] = '3'
$a_xlate[28][1] = '3-x'
$a_xlate[29][0] = '4'
$a_xlate[29][1] = '4-x'
$a_xlate[30][0] = '5'
$a_xlate[30][1] = '5-x'

; el guio

Local  $gui010  = GUICreate('Translation Example',500,400)
                  GUICtrlCreatelabel('Enter Letter/Word to Translate',100,80,300,40)
global $inp010  = GUICtrlCreateInput('',100,100,300,20)
                  GUICtrlCreatelabel('Translation',100,130,300,40)
global $out010  = GUICtrlCreateLabel('',100,150,300,20,$ss_sunken)
Local  $btn010  = GUICtrlCreatebutton('Translate',100,300,300,30)
                  GUISetState()
Local $msg

Do

    $msg = GUIGetMsg()
    select
        Case $msg = $btn010
            transpose()
        Case else
    endselect

until $msg = $gui_event_close

exit

Func transpose()

    Local $in, $out, $hit = false

    GUICtrlSetData($out010,'')
    Local $in = stringsplit(GUICtrlRead($inp010),"")

    ;_arraydisplay($in)

    For $i = 1 To $in[0]
        For $j = 0 To UBound($a_xlate,1) - 1
            If $a_xlate[$j][0] = $in[$i] Then
                $out &= $a_xlate[$j][1]
                $hit = true
            endif
        next
        If Not $hit Then $out &= '-'
        $hit = false
    Next
    GUICtrlSetData($out010,$out)
    GUICtrlSetState($inp010,$gui_focus)

endfunc

My version has the data seperate from the logic, but your is easier to understand...not sure which I like better

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

Share this post


Link to post
Share on other sites

Yes I know and I wouldn't do it the switch way for myself, but so many people are confused with arrays and since the OP was alreay comfortable with a switch-like design, I did it such.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

Try this:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiEdit.au3>
Local $Form1 = GUICreate("Form1", 257, 155, 339, 282)
Local $Input1 = GUICtrlCreateInput("", 32, 32, 201, 21)
Local $Input2 = GUICtrlCreateInput("", 32, 88, 201, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_RIGHT))
Local $Label1 = GUICtrlCreateLabel("English", 104, 8, 38, 17)
Local $Button1 = GUICtrlCreateButton("Ta7weel", 96, 120, 75, 25)
Local $Label2 = GUICtrlCreateLabel("Franco", 104, 64, 37, 17)
GUISetState(@SW_SHOW)
Local $Read1, $Read2
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $Button1
   $Read1 = StringSplit(GUICtrlRead($Input1), '', 2)
   $Read2 = ''
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   For $char In $Read1
    Switch $char
     Case 'a'
      $Read2 &= '1'
     Case 'b'
      $Read2 &= '2'
     Case 'c'
      $Read2 &= '3'
     Case 'd'
      $Read2 &= '4'
     Case 'e'
      $Read2 &= '5'
     ; insert as many Case statements as possible input characters
     Case Else
      $Read2 &= '?'
    EndSwitch
   Next
   ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   GUICtrlSetData($Input2, $Read2)  ; write new data all at once
EndSwitch
WEnd

It's really easy, helped me..and that's what i want :)

but what does this "&=" mean?

Many thanks.

jchd,

Nice. I had something like this in mind...

#include <ButtonConstants.au3>
#include <array.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

;translation table $a_xlate)
;
;          col0       col1
;       (english    (something =
;        letter)     to english letter)
;   row0    a             a-x
;   row1    b             b-x
;   row2    c             c-x
;   row3    d             d-x
;   row4    e             e-x
;   row5    f             f-x
;
;   ... and so on for all symbols (letters) to be transposed (translated)
;

Local $a_xlate[31][2]

$a_xlate[00][0] = 'a'
$a_xlate[00][1] = 'a-x'
$a_xlate[01][0] = 'b'
$a_xlate[01][1] = 'b-x'
$a_xlate[02][0] = 'c'
$a_xlate[02][1] = 'c-x'
$a_xlate[03][0] = 'd'
$a_xlate[03][1] = 'd-x'
$a_xlate[04][0] = 'e'
$a_xlate[04][1] = 'e-x'
$a_xlate[05][0] = 'f'
$a_xlate[05][1] = 'f-x'
$a_xlate[06][0] = 'g'
$a_xlate[06][1] = 'g-x'
$a_xlate[07][0] = 'h'
$a_xlate[07][1] = 'h-x'
$a_xlate[08][0] = 'i'
$a_xlate[08][1] = 'i-x'
$a_xlate[09][0] = 'j'
$a_xlate[09][1] = 'j-x'
$a_xlate[10][0] = 'k'
$a_xlate[10][1] = 'k-x'
$a_xlate[11][0] = 'l'
$a_xlate[11][1] = 'l-x'
$a_xlate[12][0] = 'm'
$a_xlate[12][1] = 'm-x'
$a_xlate[13][0] = 'n'
$a_xlate[13][1] = 'n-x'
$a_xlate[14][0] = 'o'
$a_xlate[14][1] = 'o-x'
$a_xlate[15][0] = 'p'
$a_xlate[15][1] = 'p-x'
$a_xlate[16][0] = 'q'
$a_xlate[16][1] = 'q-x'
$a_xlate[17][0] = 'r'
$a_xlate[17][1] = 'r-x'
$a_xlate[18][0] = 's'
$a_xlate[18][1] = 's-x'
$a_xlate[19][0] = 't'
$a_xlate[19][1] = 't-x'
$a_xlate[20][0] = 'u'
$a_xlate[20][1] = 'u-x'
$a_xlate[21][0] = 'v'
$a_xlate[21][1] = 'v-x'
$a_xlate[22][0] = 'w'
$a_xlate[22][1] = 'w-x'
$a_xlate[23][0] = 'x'
$a_xlate[23][1] = 'x-x'
$a_xlate[24][0] = 'y'
$a_xlate[24][1] = 'y-x'
$a_xlate[25][0] = 'z'
$a_xlate[25][1] = 'z-x'
$a_xlate[26][0] = '1'
$a_xlate[26][1] = '1-x'
$a_xlate[27][0] = '2'
$a_xlate[27][1] = '2-x'
$a_xlate[28][0] = '3'
$a_xlate[28][1] = '3-x'
$a_xlate[29][0] = '4'
$a_xlate[29][1] = '4-x'
$a_xlate[30][0] = '5'
$a_xlate[30][1] = '5-x'

; el guio

Local  $gui010  = GUICreate('Translation Example',500,400)
                  GUICtrlCreatelabel('Enter Letter/Word to Translate',100,80,300,40)
global $inp010  = GUICtrlCreateInput('',100,100,300,20)
                  GUICtrlCreatelabel('Translation',100,130,300,40)
global $out010  = GUICtrlCreateLabel('',100,150,300,20,$ss_sunken)
Local  $btn010  = GUICtrlCreatebutton('Translate',100,300,300,30)
                  GUISetState()
Local $msg

Do

    $msg = GUIGetMsg()
    select
        Case $msg = $btn010
            transpose()
        Case else
    endselect

until $msg = $gui_event_close

exit

Func transpose()

    Local $in, $out, $hit = false

    GUICtrlSetData($out010,'')
    Local $in = stringsplit(GUICtrlRead($inp010),"")

    ;_arraydisplay($in)

    For $i = 1 To $in[0]
        For $j = 0 To UBound($a_xlate,1) - 1
            If $a_xlate[$j][0] = $in[$i] Then
                $out &= $a_xlate[$j][1]
                $hit = true
            endif
        next
        If Not $hit Then $out &= '-'
        $hit = false
    Next
    GUICtrlSetData($out010,$out)
    GUICtrlSetState($inp010,$gui_focus)

endfunc

My version has the data seperate from the logic, but your is easier to understand...not sure which I like better

kylomas

It's a little difficult... but the same idea, i'll study it ;)

thanks for ur help :D

Edited by Command3r

[font="arial, helvetica, sans-serif;"]Advice for you[/font][font="arial, helvetica, sans-serif;"]: [/font][u]Search[/u] before posting.

 

[font="arial, helvetica, sans-serif;"] *********** Problem solved? if yes [/font][color=rgb(0,0,0);font-family:arial, helvetica, sans-serif;] *********[/color]

[font="arial, helvetica, sans-serif;"]******* press "Mark Solved" button. *******[/font]

Share this post


Link to post
Share on other sites

Command3r,

Use whatever you are comfortable with. There is seldom "one" right way to do something...

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

Share this post


Link to post
Share on other sites

$var &= "abc" concatenates the string "abc" to $var.

All this is in the help file under Operators.

Glad it worked for you.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By roeselpi
      hello again,
      it has been a long time since i have been here and a long time since i last used autoit. ever so often when the time allows me to, then i follow up on an idea that i had a long time ago. i have done all the work on paper but now it is up to writing it in autoit and i keep stumbling over many little issues here and there. sometimes after a few days i will try again and get a step further but sometimes it just will not help no matter how long i try and think about a solution. for most of you it will be the basics but for me it is not all that easy, but at least i give it a try.
      right, down to business:
      here is my code:
      #include <MsgBoxConstants.au3> #include <StringConstants.au3> #include <Array.au3> #include <String.au3> ; ; PART 1: define replacements and check with msgbox ; Global $y, $z $y = "Yes" $z = "No" MsgBox(0,"replacements", $y & @CRLF & $z) ;the replacements in a message box ; ; PART 2: set the texts and check via console and msgbox ; Global $my1string = "abab" ;the first specified text MsgBox(0,"my1string", $my1string) ;the message box to output the first specified text Global $my2string = "icic" ;the second specified text MsgBox(0,"my2string", $my2string) ;the message box to output the second specified text ; ; PART 3: transform the strings to individual arrays ; $my1array = StringSplit($my1string, "") $my1array[0] = "" _ArrayDelete($my1array, 0) _ArrayDisplay($my1array, "my1array") ;the display of the first specified array $my2array = StringSplit($my2string, "") $my2array[0] = "" _ArrayDelete($my2array, 0) _ArrayDisplay($my2array, "my2array") ;the display of the first specified array ; ; PART 4: create an empty array for filling ; Global $OutputArray[4] $OutputArray[0] = "" _ArrayDisplay($OutputArray, "OutputArray") ;the display of the first specified array ; ; PART 5: compare & fill empty OutputArray with data after evaluation ; Global $i, $j, $k For $i = 0 to UBound($my1array) -1 For $j = 0 to UBound($my2array) -1 For $k = 0 to UBound($OutputArray) -1 If $my1array[$i] = "a" And $my2array[$j] = "i" Then $OutputArray[$k] = $y Else $OutputArray[$k] = $z EndIf Next Next Next _ArrayDisplay($OutputArray, "OutputArray") ;the display of the Newly filled Array In "Part 2" i make a string that is converted to an array in "Part 3" ... Now, I know that "a" and "i" are always in the exact same spot in both arrays and so i wanted to compare this and make a further array to document my findings by saying "yes" or "no" ... however my new array keeps saying just "no" allthough i can clearly see and know that it should say:
      yes no yes no my guess is that there is something wrong within my for-loops and that the counting is somehow "off" i guess that when the first for-loop is finished it reaches the second whilst the second for-loop is checking the first which would explain why it always says "no" instead of seeing the obvious.
      so my question would be: what is wrong with my for-loop? or where am i making an error that ultimately gives me the wrong results?
      help is much appreciated.
      kind regards
      roeselpi
       
       
      PS: sorry for my not so great english spelling ... stupid german sitting here trying out intermediate english skills.
    • By Zobu
      Hey Guys,
      I want to add a new checkbox with its own variable every time the add button is clicked.
      The added checkboxes should remain when I close the window or exit the script and when I reopen I should be able to add new checkboxes aswell.
      here is what I have so far..
      #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> #include <GuiButton.au3> $test = GUICreate("adding test", 475, 345, 500, 175) $Check1 = GUICtrlCreateCheckbox("Checkbox 1", 15, 25, 300, 25) $Button = GUICtrlCreateButton("Add", 365, 25, 90, 20) $Check2 = GUICtrlCreateCheckbox("Checkbox 2", 15, 50, 300, 25) $Check3 = GUICtrlCreateCheckbox("Checkbox 3", 15, 75, 300, 25) GUICtrlSetState($Check2, $GUI_HIDE) GUICtrlSetState($Check3, $GUI_HIDE) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ; Exit Case $Button GUICtrlSetPos($Check2, 15, 50, 300, 25) GUICtrlSetState($Check2, $GUI_SHOW) Case $Button GUICtrlSetPos($Check3, 15, 75, 300, 25) GUICtrlSetState($Check3, $GUI_SHOW) EndSwitch WEnd  
    • By levila
      Hi guys, really need your help. How can i check every 5 min if my text file include String "Markus". Btw i need this function to run on my Logs file that are updated whenever some event is triggered (logs appear in same txt file). So i did test some codding to test isit possible.
      But somehow, it only detect for the 1st time String check, and keep coming the same output every time, it didnt check/read on the current txt file that has been updated.
      For this purpose i update txt file manually so i put String "Markus" and check, and try to remove it agn.
      Here is my code:
       
      $file = FileOpen("c:\hello.txt", 0) $read = FileRead($file) func _CheckString() If StringInStr($read, "Markus") Then $position = StringInStr($read, "Markus") MsgBox(0,"","Alert Found - Logs Line No "&$position, 5) FileClose($file) Else MsgBox(0,"","No Alert found", 5) FileClose($file) EndIf EndFunc $Mins = 0.5 ; i change to fewer min for testing purpose $Timer = TimerInit() While 1 If TimerDiff($Timer) > ($Mins * 60000) Then ; count per minute multiplied by 60sec. _CheckString() ConsoleWrite("30 Sec have passed!" & @CRLF) ; console to see if its running. $Timer = TimerInit() EndIf WEnd  
    • By DigiBox
      Hello!
      Please help me with this small problem I've encountered while learning to make GUI.
      I'm not able to get the set slider values out of sliders and I can't figure out why.
      The slider value in the example is preset to 1, but whatever I set the slider to, it returns the value 3 when I click Apply and I havn't set any value to 3.
      Where is that 3 coming from?
       
      #include <SliderConstants.au3> #include <MsgBoxConstants.au3> #include <GUIConstantsEx.au3> Global $LRSlider Opt("GUIOnEventMode", 1) Global $Form1 = GUICreate("test slider", 200, 200, -1, -1) Global $LRSlider = GUICtrlCreateSlider(50, 50, 100, 20, $TBS_TOOLTIPS) GUICtrlSetLimit($LRSlider, 50, 1) GUICtrlSetData($LRSlider, 1) GUISetOnEvent($GUI_EVENT_CLOSE, "Exit1") Global $ApplyButton = GUICtrlCreateButton("APPLY", 100, 150, 89, 17) GUICtrlSetOnEvent($ApplyButton, "Apply") GUISetState(@SW_SHOW) Func Apply() GUICtrlRead($LRSlider) MsgBox(0, 0, $LRSlider) GUICtrlSetData($LRSlider, $LRSlider) EndFunc ;==>Apply Func Exit1() Exit EndFunc ;==>Exit1 While 1 Sleep(200) WEnd  
    • By XinYoung
      Hello all! I hope everyone is enjoying their holiday festivities. 
      I'm working on a script that involves copying a string of text from an Excel workbook and searching for it in a particular website's search tool. If a result is found, it will do something. If not, it will do something else.
      So far, it can successfully execute the search -- and then it shows me the results in an array.
      Screenshot of the successful search:

      The search results in an array:

       
      Here's the code (sorry for all my comments):
      ;~ All the functions this app performs require the external files listed here. So, theyre "included". #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinAPIFiles.au3> #include <Array.au3> #include <File.au3> #include <Excel.au3> #include <DateTimeConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIShellEx.au3> #include <Date.au3> #include <ComboConstants.au3> #include <Misc.au3> #include <WinAPIProc.au3> #include <WinAPISys.au3> #include <WinAPIConstants.au3> #include <Crypt.au3> #include <ColorConstants.au3> #include <guimenu.au3> #include <IE.au3> ;~ Kill all functions and close the app at anytime by pressing F4. HotKeySet("{F4}", "_Exit") ;~ Keep track whether or not a file is selected. When the program first opens, a file is currently not selected. Global $FileChosen = 0 ;~ The app must remember certain strings of text: ;~ 1. Login page Global $urlBBLogin = "website.com" ;~ 2. Credentials Global $bbUsername = "USER" Global $bbPassword = "PW" ;~ 3. Search page Global $urlBBCourseSearch = "website.com/search" ;~ When you launch the app, the UI gets built and is displayed to the user in the center of the screen. the "Function" buttons are disabled until a file is chosen. $MasterUI = GUICreate("Master Re-Creator", 469, 145, -1, -1) $Label1 = GUICtrlCreateLabel("Choose the Excel file", 8, 8, 103, 17) $Select = GUICtrlCreateButton("Select File", 16, 32, 75, 25) $FileName = GUICtrlCreateLabel("[No File Selected]", 104, 40, 88, 17) $Group1 = GUICtrlCreateGroup("Functions", 8, 72, 449, 65) $CheckCourse = GUICtrlCreateButton("Check Courses Exist", 24, 96, 123, 25) GUICtrlSetState(-1, $GUI_DISABLE) $DeleteCourse = GUICtrlCreateButton("Delete Courses", 168, 96, 123, 25) GUICtrlSetState(-1, $GUI_DISABLE) $CopyCourse = GUICtrlCreateButton("Copy Courses", 312, 96, 123, 25) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) ;~ While the UI is open, it listens for triggers (in this case, button presses). While 1 $UI = GUIGetMsg() Select ;~ If the app is closed, the _Exit() function is performed (same function the F4 hotkey calls). Case $UI = $GUI_EVENT_CLOSE _Exit() ;~ The user has clicked the "Select File" button, the _LocateGetFileName() function is performed. Go there. Case $UI = $Select _LocateGetFileName() ;~ The user has clicked the "Check Courses Exist" button. Case $UI = $CheckCourse _CheckCourses() ;~ Other buttons are not ready EndSelect WEnd ;~ The user clicked the "Select File" button. This function will execute now. Func _LocateGetFileName() ;~ Prepare the app to take note of the details of a file. Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" ;~ Open a File Explorer to allow the user to select a file. Only Excel files are allowed to be chosen. Global $ChosenFileName = FileOpenDialog("Locate File", @DesktopDir, "Excel Files (*.xlsx)|Excel Macro Files (*.xlsm)", BitOR(1, 2), "") If @error Then Return 0 EndIf ;~ When an Excel file is selected, remember of the files location (path), file name, and file extension. $aPathSplit = _PathSplit($ChosenFileName, $sDrive, $sDir, $sFileName, $sExtension) ;~ Show me what file I selected in a Message Box. MsgBox(0, "Selected File", $sFileName) ;~ Display the chosen file name in the UI label (previously [No File Selected]) and make it green. GUICtrlSetData($FileName, "") $FileName = GUICtrlCreateLabel($sFileName, 104, 40) $FileName = GUICtrlSetColor($FileName, 0x32CD32) ;~ A file is now selected. The "Function" buttons are now enabled. Global $FileChosen = 1 GUICtrlSetState($CheckCourse, $GUI_ENABLE) GUICtrlSetState($DeleteCourse, $GUI_ENABLE) GUICtrlSetState($CopyCourse, $GUI_ENABLE) EndFunc ;==>_LocateGetFileName ;~ The user clicked the "Check Courses" button. This function will execute now. Func _CheckCourses() ;~ Disable the "Function" buttons again to prevent multiple processes. GUICtrlSetState($CheckCourse, $GUI_DISABLE) GUICtrlSetState($DeleteCourse, $GUI_DISABLE) GUICtrlSetState($CopyCourse, $GUI_DISABLE) ;~ Open a IE window and navigate to the login page. Global $oIE = _IECreate($urlBBLogin) ;~ Recognize the form on this page (login input boxes). Local $oForm = _IEFormGetObjByName($oIE, "login") Local $oTextLogin = _IEFormElementGetObjByName($oForm, "user_id") Local $oTextPass = _IEFormElementGetObjByName($oForm, "password") ;~ Enter the Automation user credentials into the form. _IEFormElementSetValue($oTextLogin, $bbUsername) _IEFormElementSetValue($oTextPass, $bbPassword) ;~ Click the Login button. _IEFormSubmit($oForm) ;~ Now that were logged in, navigate to the course search page. _IENavigate($oIE, $urlBBCourseSearch) ;~ Change the search criteria to "Course ID" _bbCourseSearchCategoryChange("Course ID") ;~ Open the selected Excel file Local $oAppl = _Excel_Open() Local $oWorkbook = _Excel_BookOpen($oAppl, $ChosenFileName, Default, Default, True) ;~ Copy just whats in cell A1 (for now) _Excel_RangeCopyPaste($oWorkbook.Worksheets(1), "A1") Global $WhatsCopied = ClipGet() ;~ Paste whats copied into the search text box and click submit Local $oForm = _IEGetObjByName($oIE, "courseManagerFormSearch") Local $oSearchString = _IEFormElementGetObjByName($oForm, "courseInfoSearchText") _IEFormElementSetValue($oSearchString, $WhatsCopied) _IEFormSubmit($oForm) ;~ Lets see what we got from the search Local $oBBTable = _IETableGetCollection($oIE, 2) Local $aBBTableData = _IETableWriteToArray($oBBTable) _ArrayDisplay($aBBTableData) EndFunc ;==>_CheckCourses ;~ This function allows changing the search criteria. Func _bbCourseSearchCategoryChange($sCategoryToSearch) Local $aSearchCategory[6] = ["Course ID", "Course Name", "Description", "Instructor", "Data Source Key", "Term"] Local $oForm = _IEGetObjByName($oIE, "courseManagerFormSearch") Local $oSearchCategory = _IEGetObjByName($oForm, "courseInfoSearchKeyString") _IEAction($oSearchCategory, "focus") _IEFormElementOptionSelect($oSearchCategory, $aSearchCategory[$sCategoryToSearch], 1, "byText") EndFunc ;==>_bbCourseSearchCategoryChange ;~ All exit commands, including F4, calls this function Func _Exit() Exit EndFunc ;==>_Exit  
      My main question is: How do I create an If... Then based on what is found in the search results? I need additional tasks to run if Col 1, Row 2 in the array contains the exact string I searched for. (Am I going about this the right way?)
      My next question (I might make a new thread for): How do I make the whole thing loop, as in, copy the next cell in the Excel sheet and do the whole thing over again until there's no more? I understand that a For/Next loop thingy would be used. I just don't know how. Loops are really confusing to me.
      Thank you all for your guidance and have a happy new year!
×
×
  • Create New...