Jump to content
Sign in to follow this  
Command3r

[Resolved]Help me completing this script

Recommended Posts

Command3r

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
jchd

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
Command3r

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
Command3r

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
jchd

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
kylomas

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
jchd

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
Command3r

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
kylomas

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
jchd

$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  

  • Similar Content

    • ShakeelAhmad
      By ShakeelAhmad
      I've to upload different number of photos online in different assignments. There is a problem that all photos cannot be selected at once to upload. I have to choose and upload photos one by one. For this purpose I have made a script to automate whatever I have to do manually for choosing and uploading photos one by one.
      Please see my script below and check the last "MouseClick" command. This command clicks the button to choose and upload next photo. The problem I'm facing is; the last "MouseClick" works 1 step extra when all photos have been selected and uploaded. I mean if 7 photos are to be uploaded, this command opens the box from where next photo is selected and uploaded then it again opens the box and next photo is choosen and so on.... when last photo is selected and uploaded, this button once again opens the box. When all photos are uploaded, it should not click the button to select next photo. Please suggest how can I resolve this issue.
      #include <AutoItConstants.au3> Sleep(200) HotKeySet("{ESC}","Quit") ;Press ESC key to quit Send("{ALT DOWN}") Send("{TAB}") Send("{ALT UP}") Sleep(200) Local $photos = InputBox("Question", "How many photos to upload?", "#", "", _ - 1, -1, 0, 0) ; How many photos to upload Local $selector = 0 While $photos <> $selector MouseClick("Left", 281, 238, 1) ; mouse click on very first photo in the box. if $selector = 0 Then Send("{ENTER}") ; for selecting very first photo from "open" window. Sleep(800) Else sleep(200) Send("{RIGHT " & $selector & "}") ; for selecting 2nd to onward photos from "open" window. sleep(1000) Send("{ENTER}") sleep(1000) EndIf MouseClick("Left", 495, 198, 1) ; for clicking a button to choose next photo to upload $selector = $selector + 1 WEnd Beep(1500, 300) ; beep when all photos uploaded Exit Regards,
       
      Shakeel
    • WoodGrain
      By WoodGrain
      Hi guys,
      I'm learning about GUI's, I'm trying the below code, the idea being if I press the letter "e" while I have the GUI open I want the label color to change to green (I'm using a UDF for label colors). But every time I press "e" on my keyboard I just get a "ding" sound from my speakers and nothing changes with the label.
      I've looked at using something like "While GUIGetMsg() <> $GUI_EVENT_CLOSE" as I've seen it in other code instead of "While 1", but I don't think it's relevant.
      #include <GUIConstantsEx.au3>; for GUI... #include <GUIRichLabel.au3>; UDF for rich text label fonts #include <Misc.au3>; for _IsPressed $myLetter = "e" $hGUI = GUICreate("test", 700, 60) $lbl2 = _GUICtrlRichLabel_Create($hGUI, '<font color="purple">' & $myLetter & '</font>', 10, 10); , 260, 25 GUISetState(@SW_SHOW) Local $hDLL = DllOpen("user32.dll") While 1 if _IsPressed(Hex($myLetter), $hDLL) Then While _IsPressed(Hex($myLetter), $hDLL) Sleep(250) WEnd _GUICtrlRichLabel_SetData($lbl2, '<font color="green">' & $myLetter & '</font>') Sleep(2000) DllClose($hDLL) Exit EndIf Sleep(50) WEnd DllClose($hDLL) I am using an array of letters that I'm wanting to do this for, but as I can't get it to work I've stripped it down to the simplest code I can think of to try and get this working first. Appreciate any help.
      Thanks!
    • OneSolution
      By OneSolution
      Hi guys! I have these checkbox that I'm trying to click on. They have the same inner-text string but a different ID. Sometime there can be as many as 4 checkbox
      with the same string but the ID is always different. I tried a few methods down below but I'm unable to make any real results. Any suggestions or solutions I would
      appreciate it very much.
      <ul><li class="cx-list-item-wrapper" data-day="Aug 2 2018 07:27:37 GMT-0700 (Pacific Daylight Time)"><div class=""><div class="cx-list-item-container"><div class="cx-list-item cx-item-icon-2 pointer-cursor"><div class="cx-item-contents cx-item-time col-md-2"><!-- react-text: 675 -->Morning<!-- /react-text --><!-- react-text: 676 -->&nbsp;<!-- /react-text --></div><div class="cx-item-contents col-md-1"><!-- react-text: 678 -->OTHER<!-- /react-text --><!-- react-text: 679 -- >&nbsp;<!-- /react-text --></div><div class="cx-item-contents col-md-2"><!-- react-text: 681 -->8:30 AM<!-- /react-text --><!-- react-text: 682 -->&nbsp;<!-- /react-text --></div><div class="cx-item-contents col-md-2"><!-- react-text: 684 -->10:30 AM<!-- /react-text --><!-- react-text: 685 -->&nbsp;<!-- /react-text -- ></div><div class="cx-item-contents col-md-1"><!-- react-text: 687 -->SRV<!-- /react-text --><!-- react-text: 688 -->&nbsp;<!-- /react-text --></div></div></div><div class="pull-right cx-listitem-chk"><div><input id="cx_checkbox1" class="cx-fa-chk cx-selfschedule-chk" value="on" type="checkbox"><label for="cx_checkbox1"></label></div></div></div></li><li class="cx-list-item-wrapper" data-day="Aug 2 2018 07:27:37 GMT-0700 (Pacific Daylight Time)"><div class=""><div class="cx-list-item-container"><div class="cx-list-item cx-item-icon-2 pointer-cursor"><div class="cx-item-contents cx-item-time col-md-1"><!-- react-text: 698 -- >Morning<!-- /react-text --><!-- react-text: 699 -->&nbsp;<!-- /react-text --></div><div class="cx-item-contents col-md-1"><!-- react-text: 701 -->OTHER<!-- /react- text --><!-- react-text: 702 -->&nbsp;<!-- /react-text --></div><div class="cx-item-contents col-md-2"><!-- react-text: 704 -->8:30 AM<!-- /react-text --><!-- react-text: 705 -->&nbsp;<!-- /react-text --></div><div class="cx-item-contents col-md-2"><!-- react-text: 707 -->2:30 PM<!-- /react-text --><!-- react-text: 708 -- >&nbsp;<!-- /react-text --></div><div class="cx-item-contents col-md-1"><!-- react-text: 710 -->SRV<!-- /react-text --><!-- react-text: 711 -->&nbsp;<!-- /react-text --></div></div></div><div class="pull-right cx-listitem-chk"><div><input id="cx_checkbox2" class="cx-fa-chk cx-selfschedule-chk" value="on" type="checkbox"><label for="cx_checkbox2"></label></div></div></div></li></ul> I tried the _IETagNameGetCollection() but it only check the box but doesn't fire the event! And I'm unable to submit that without a click action.
      Func _Box1() $oInputs = _IETagNameGetCollection($oIE, "input") For $oInput In $oInputs If $oInput.id == "cx_checkbox1" Then $oInput.checked = true Next Sleep(10) ToolTip('box1') EndFunc ;==>_Box1 I also tried click by text.The boxes do get check by a click but the problem with that is it will select every box that has the same string. I'm allowed only to check 1 box selection at a time per day for the submit button to work.  Any preference to select only the second box and bypass the other?
      Func _Morning() For $a In _IETagNameGetCollection($oIE, "div") If StringInStr(_IEPropertyGet($a, "innerText"), "Morning") Then _IEAction($a, "click") EndIf Next Sleep(10) ToolTip('Morning selected') EndFunc ;==>Morning The last method I tried was _IEGetObjById(). It doesn't click or respond to the checkbox.
      Func _Click1() $oChk = _IEGetObjById($oIE, "cx_checkbox1") _IEAction($oChk, 'click') Sleep(20) ToolTip('box1') EndFunc ;==>_Click1  
    • AndreasNWWWWW
      By AndreasNWWWWW
      Hi, i'm curious if this is even possible, i want to do an action if the ini file contains current values under a section.
      for my test i'm looking for 100,200,300,400,500
      and if any of those excits i want to pop a msgbox with the number in the section.
      i can in my example find one, but it does not check everyone. why?  what am i missing?
      Local $iscore810[5] = [100,200,300,400,500] Local $iMax800 = 5 While 1 ;~     Send("{pause}") ;;func les ini fil     $var = IniReadSection("Area.ini", "modus")     If @error Then         MsgBox(4096, "Error", "Unable to read section.")     Else          For $number = 1 To $var[0][0] If $var[$number][1] == $iscore810[3] Then       MsgBox($MB_SYSTEMMODAL, "FAnt den på", $var[$number][0], 5) EndIf                       Next     EndIf     exit WEnd  
    • Aleksandar
      By Aleksandar
      So can anyone help me ? I need to restart program when condition is not met ...

×