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

    • Aleksandar
      By Aleksandar
      So can anyone help me ? I need to restart program when condition is not met ...

    • DynamicRookie
      By DynamicRookie
      Hey there!
       
      I've been developing a artificial intelligence.

      My first hard task was letting the A.I know when a sentence is found in memory with different words
      What i tried to do here is simply, get all the words in user sentence that could be used
      as a identifier
              
              example: Steve Jobs
              
              then identify the sentence purpose with the words we found in the past "for" loop
              
              example: Do/Know/You/Who/Steve/Jobs
              
              Compare the example in the following matching sentences in memory.
              
              1-Steve jobs was a known person
              2-Do you know who barack obama is?
              3-Do you know Steve jobs?
              4-Do you know who steve jobs is?
              5-How much money steve jobs had
              
              Then find the sentence that has way more matches than the other ones, remember that if the identifier words were not found
              (Steve jobs) then the sentence is invalid.
              
              Every sentence has a different answer and is important that the right one is chosen.
              
      If there's no more than the half of words in matches, then assign a variable the result of function, such as a return but for a global var.
      I couldn't figure out how to do that with StringRegExp.
       
      I honestly need help with detecting identifiers on memory sentences.
      I would also like to let the AI know typos, meaning that moeny and money means the same thing.
      Any help is hugely appreciated.

       
    • Eli_jahbot
      By Eli_jahbot
      my esteemed autoits,
      i need your help once again. The bold and italics below are what i will be referring to. I need a message box to exit the script if Cancel is pressed and to continue the script if OK is pressed. I have tried multiple ways to do this to no avail. Can someone please breakdown how i go about this via Message box, and or Input box as I'm sure they will follow the same logic. I appreciate your time and assistance.
       
      Example:
      global $url, $username, $password, $sspassword
      $url = "https://securegateway.fairview.org"
      $username = "XXX"
      $password = "YYY"
      $sspassword = "ZZZ"
      #include <Constants.au3>
      #include <msgboxconstants.au3>
      ShellExecute ($url)
      WinWaitActive("window")
      send($username)
      send("{tab}")
      send($password)
      send("{enter}")
      msgbox($mb_okcancel, "Wait for the page to load then select OK to continue script", "Wait for the page to load then select OK to continue script")
      if($idok)
      send("+{tab 8}")
      send("{enter}")
      if ($idcancel) then Exit
      EndIf
    • LoneWolf_2106
      By LoneWolf_2106
      Hi everybody,
      i have a log file with several entries like the following one:
      INFO [26.04.2017 11:37:48] [main] XML-Data: <online-activation> <general> <userid>XYZ</userid> <mac-address/> <OU>VG-DE</OU> <ROLE>KDT</ROLE> <FOA>PRO;FC;DOM;MDD</FOA> <BRD>XYZ;IMP</BRD> </general> <applications> <app expiration-date="2017-10-01" name="BB-INFO"/> <app expiration-date="2017-10-01" name="MMSKD"/> <app expiration-date="2017-10-01" name="FM-TOOL"/> <app expiration-date="2017-04-05" name="WEB-BTD"/> <app expiration-date="2017-10-01" name="OFFLINE-BTD"/> <app expiration-date="2017-10-01" name="MDU-UPD"/> <app expiration-date="2017-10-01" name="MDU"/> <app expiration-date="2017-04-05" name="WEB-WDA"/> <app expiration-date="2017-04-05" name="WEB-ETD"/> <app expiration-date="2017-10-01" name="OFFLINE-WDA"/> <app expiration-date="2017-10-01" name="OFFLINE-ETD"/> </applications> </online-activation>  
      I need to collect all the XML-Data, my search doesn't work:
       
      Func FileSearch() $j=0 For $i = 0 To UBound($content_array) - 1 $search_result=StringInStr($content_array[$i],$search) If $search_result<>0 Then ReDim $searchResultArray[UBound($searchResultArray) + 1] $searchResultArray [$j] = $content_array[$i] _ArrayDisplay($searchResultArray) $j+=1 EndIf Next EndFunc If i search for "online-activation", it retrieves only the first and the last tag, but not what is within.
      In addition, when i use FileReadToArray, all the entries between <online-activation> and </online-activation>

    • Rimoun
      By Rimoun
      Hello everyone
      I would like to have some help regarding my issue.
      I am trying to extract some information from excel sheet, I use _Excel_RangeFind then I get the array for the value then I check the array. In case the array is true the next will be to get some information based on the extracted array if no array because the value is not found it gives a messages box that the value is not found.
      My problem that the button works for one time only if i tried any value which exist in the sheet it gives me that value not found.
      I suspect that there is a problem regarding While loop.
      here is my code
      #include <GUIConstantsEx.au3> #include <WinAPI.au3> #Include <GuiListBox.au3> #include <WindowsConstants.au3> #include <Array.au3> #include <Excel.au3> #include <MsgBoxConstants.au3> #include <ExcelConstants.au3> if FileExists ("result.txt") Then Sleep (100) Else readxl() EndIf Global $oExcel = _Excel_Open(False,False) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Global $oWorkbook = _Excel_BookOpen($oExcel, "D:\info.xlsx",False,False) If @error Then MsgBox($MB_SYSTEMMODAL, "Excel Error", "Error opening workbook '" & $oWorkbook & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oExcel) Exit EndIf Local $lab1 = _Excel_RangeRead($oWorkbook, Default,"B1") Local $lab2 = _Excel_RangeRead($oWorkbook, Default,"C1") Local $lab3 = _Excel_RangeRead($oWorkbook, Default,"D1") Local $lab4 = _Excel_RangeRead($oWorkbook, Default,"E1") Global $sResult1,$sResult2,$sResult3,$sResult4,$sResult5,$sResult6 Global $asKeyWords = stringsplit (FileRead (@ScriptDir & "\result.txt"),@CRLF) Global Const $xlUp = -4162 ;~ _Main() Local $hGUI, $hList, $hInput, $aSelected, $sChosen, $hUP, $hDOWN, $hENTER, $hESC Local $sCurrInput = "", $aCurrSelected[2] = [-1, -1], $iCurrIndex = -1, $hListGUI = -1 $hGUI = GUICreate("Rimo System", 253, 270, 192, 124) Global $hInput = GUICtrlCreateInput("", 24, 48, 169, 21) Global $Label1 = GUICtrlCreateLabel("Rimo System", 80, 16, 150, 25) GUICtrlSetFont(-1, 14, 800, 0, "MS Serif") Global $Input2 = GUICtrlCreateInput("", 72, 144, 161, 21) Global $Input3 = GUICtrlCreateInput("", 72, 176, 161, 21) Global $Input4 = GUICtrlCreateInput("", 72, 208, 161, 21) Global $Input5 = GUICtrlCreateInput("", 72, 240, 161, 21) $Input6 = GUICtrlCreateInput("", 72, 272, 161, 21) $Input7 = GUICtrlCreateInput("", 72, 304, 161, 21) $Button1 = GUICtrlCreateButton("Get Info", 72, 88, 89, 33) $Label2 = GUICtrlCreateLabel("Label2", 16, 144, 36, 17) GUICtrlSetData( -1,$lab1) $Label3 = GUICtrlCreateLabel("Label3", 16, 176, 36, 17) GUICtrlSetData( -1,$lab2) $Label4 = GUICtrlCreateLabel("Label4", 16, 208, 36, 17) GUICtrlSetData( -1,$lab3) $Label5 = GUICtrlCreateLabel("Label5", 16, 240, 36, 17) GUICtrlSetData( -1,$lab4) $Label6 = GUICtrlCreateLabel("", 16, 272, 36, 17) $Label7 = GUICtrlCreateLabel("", 16, 304, 36, 17) $Button2 = GUICtrlCreateButton("Cancel", 112, 416, 121, 25) GUISetState(@SW_SHOW, $hGUI) Global $sSearch = guictrlread ($hInput) $hUP = GUICtrlCreateDummy() $hDOWN = GUICtrlCreateDummy() $hENTER = GUICtrlCreateDummy() $hESC = GUICtrlCreateDummy() Dim $AccelKeys[4][2] = [["{UP}", $hUP], ["{DOWN}", $hDOWN], ["{ENTER}", $hENTER], ["{ESC}", $hESC]] GUISetAccelerators($AccelKeys) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Button2 Exit Case $Button1 Global $aResult = _Excel_RangeFind($oWorkbook, guictrlread($hInput) ,"A2:A2000") Global $aExtract = _ArrayExtract($aResult, 0, 0, 2, 2) if _elementExists($aExtract,0) Then getdata() Else MsgBox(0,"","Value Does Not Exist") EndIf Case $hESC If $hListGUI <> -1 Then ; List is visible. GUIDelete($hListGUI) $hListGUI = -1 Else ExitLoop EndIf Case $hUP If $hListGUI <> -1 Then ; List is visible. $iCurrIndex -= 1 If $iCurrIndex < 0 Then $iCurrIndex = 0 EndIf _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hDOWN If $hListGUI <> -1 Then ; List is visible. $iCurrIndex += 1 If $iCurrIndex > _GUICtrlListBox_GetCount($hList) - 1 Then $iCurrIndex = _GUICtrlListBox_GetCount($hList) - 1 EndIf _GUICtrlListBox_SetCurSel($hList, $iCurrIndex) EndIf Case $hENTER If $hListGUI <> -1 And $iCurrIndex <> -1 Then ; List is visible and a item is selected. $sChosen = _GUICtrlListBox_GetText($hList, $iCurrIndex) EndIf Case $hList $sChosen = GUICtrlRead($hList) EndSwitch Sleep(10) $aSelected = _GetSelectionPointers($hInput) If GUICtrlRead($hInput) <> $sCurrInput Or $aSelected[1] <> $aCurrSelected[1] Then ; Input content or pointer are changed. $sCurrInput = GUICtrlRead($hInput) $aCurrSelected = $aSelected ; Get pointers of the string to replace. $iCurrIndex = -1 If $hListGUI <> -1 Then ; List is visible. GUIDelete($hListGUI) $hListGUI = -1 EndIf $hList = _PopupSelector($hGUI, $hListGUI, _CheckInputText($sCurrInput, $aCurrSelected)) ; ByRef $hListGUI, $aCurrSelected. EndIf If $sChosen <> "" Then GUICtrlSendMsg($hInput, 0x00B1, $aCurrSelected[0], $aCurrSelected[1]) ; $EM_SETSEL. _InsertText($hInput, $sChosen) $sCurrInput = GUICtrlRead($hInput) GUIDelete($hListGUI) $hListGUI = -1 $sChosen = "" EndIf WEnd GUIDelete($hGUI) Func _CheckInputText($sCurrInput, ByRef $aSelected) Local $sPartialData = "" If (IsArray($aSelected)) And ($aSelected[0] <= $aSelected[1]) Then Local $aSplit = StringSplit(StringLeft($sCurrInput, $aSelected[0]), " ") $aSelected[0] -= StringLen($aSplit[$aSplit[0]]) If $aSplit[$aSplit[0]] <> "" Then For $A = 1 To $asKeyWords[0] If StringLeft($asKeyWords[$A], StringLen($aSplit[$aSplit[0]])) = $aSplit[$aSplit[0]] And $asKeyWords[$A] <> $aSplit[$aSplit[0]] Then $sPartialData &= $asKeyWords[$A] & "|" EndIf Next EndIf EndIf Return $sPartialData EndFunc ;==>_CheckInputText Func _PopupSelector($hMainGUI, ByRef $hListGUI, $sCurr_List) Local $hList = -1 If $sCurr_List = "" Then Return $hList EndIf $hListGUI = GUICreate("", 280, 160, 23, 62, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST, $WS_EX_MDICHILD), $hMainGUI) $hList = GUICtrlCreateList("", 0, 0, 170, 150, BitOR(0x00100000, 0x00200000)) GUICtrlSetData($hList, $sCurr_List) GUISetControlsVisible($hListGUI) ; To Make Control Visible And Window Invisible. GUISetState(@SW_SHOWNOACTIVATE, $hListGUI) Return $hList EndFunc ;==>_PopupSelector Func _InsertText(ByRef $hEdit, $sString) #cs Description: Insert A Text In A Control. Returns: Nothing #ce Local $aSelected = _GetSelectionPointers($hEdit) GUICtrlSetData($hEdit, StringLeft(GUICtrlRead($hEdit), $aSelected[0]) & $sString & StringTrimLeft(GUICtrlRead($hEdit), $aSelected[1])) Local $iCursorPlace = StringLen(StringLeft(GUICtrlRead($hEdit), $aSelected[0]) & $sString) GUICtrlSendMsg($hEdit, 0x00B1, $iCursorPlace, $iCursorPlace) ; $EM_SETSEL. EndFunc ;==>_InsertText Func _GetSelectionPointers($hEdit) Local $aReturn[2] = [0, 0] Local $aSelected = GUICtrlRecvMsg($hEdit, 0x00B0) ; $EM_GETSEL. If IsArray($aSelected) Then $aReturn[0] = $aSelected[0] $aReturn[1] = $aSelected[1] EndIf Return $aReturn EndFunc ;==>_GetSelectionPointers Func GUISetControlsVisible($hWnd) ; By Melba23. Local $aControlGetPos = 0, $hCreateRect = 0, $hRectRgn = _WinAPI_CreateRectRgn(0, 0, 0, 0) Local $iLastControlID = _WinAPI_GetDlgCtrlID(GUICtrlGetHandle(-1)) For $i = 3 To $iLastControlID $aControlGetPos = ControlGetPos($hWnd, '', $i) If IsArray($aControlGetPos) = 0 Then ContinueLoop $hCreateRect = _WinAPI_CreateRectRgn($aControlGetPos[0], $aControlGetPos[1], $aControlGetPos[0] + $aControlGetPos[2], $aControlGetPos[1] + $aControlGetPos[3]) _WinAPI_CombineRgn($hRectRgn, $hCreateRect, $hRectRgn, 2) _WinAPI_DeleteObject($hCreateRect) Next _WinAPI_SetWindowRgn($hWnd, $hRectRgn, True) _WinAPI_DeleteObject($hRectRgn) EndFunc Func _elementExists($array, $element) If $element > UBound($array)-1 Then Return False ; element is out of the array bounds Return True ; element is in array bounds EndFunc Func getdata() ;~ Local $sResult1 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","B")) ;~ Local $sResult2 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","C")) ;~ Local $sResult3 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","D")) ;~ Local $sResult4 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","E")) ;~ Local $sResult5 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","F")) ;~ Local $sResult6 = _Excel_RangeRead($oWorkbook, Default,StringReplace(StringReplace ($aExtract[0],"$",""),"A","G")) guictrlsetdata($Input2,$sResult1) guictrlsetdata($Input3,$sResult2) guictrlsetdata($Input4,$sResult3) guictrlsetdata($Input5,$sResult4) guictrlsetdata($Input6,$sResult5) guictrlsetdata($Input7,$sResult6) _Excel_Close($oExcel,Default,True) EndFunc Func readxl() Global $oExcel = _Excel_Open(False,False) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeFind Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Global $oWorkbook = _Excel_BookOpen($oExcel, "D:\info.xlsx",False,False) LOcal Const $xlUp = -4162 With $oWorkbook.ActiveSheet ; process active sheet $oRangeLast = .UsedRange.SpecialCells($xlCellTypeLastCell) ; get a Range that contains the last used cells $iRowCount = .Range(.Cells(1, 1), .Cells($oRangeLast.Row, $oRangeLast.Column)).Rows.Count ; get the the row count for the range starting in row/column 1 and ending at the last used row/column $iLastCell = .Cells($iRowCount + 1, "B").End($xlUp).Row ProgressOn("Copying Cells", "Copying Cells progress", "0%") For $i = 2 to $iLastCell Local $total = Int(($i/$iLastCell)*100) Local $sResult3 = _Excel_RangeRead($oWorkbook, Default, "A" & $i) FileWriteLine("result.txt",$sResult3) ProgressSet(($i/$iLastCell)*100, $total & "%") Next ;~ FileWrite("result.txt",$sResult3) ProgressSet(100, "Done", "Complete") Sleep (1500) ProgressOff() _Excel_Close($oExcel,Default,True) EndWith EndFunc  
×