Jump to content

[i am completely beginner] I have question


Go to solution Solved by robertocm,

Recommended Posts

Hello friends, i just searching here and there, and then i found this forum, how-do-i-automatically-change-letters-to-other-letters-in-a-text-editor

i am really noob about scripting, i dont have much knowledge, but still i have little knowledge of it and enthusiasm for learn..i have downloaded autoscript installation also

so following these thread,

Quote

especially this line here (from that thread) .there is a reply from some user, "Decipher" he said this

Func _GenerateConverterFunction($sFileName)
    Local $aChar, $aArray = StringSplit(FileRead($sFileName), @CRLF, 1)
    ConsoleWrite("Func _ReplaceCharacters($sString)" & @CRLF)
    For $i = 1 To $aArray[0] Step 1
        $aChar = StringSplit(StringStripWS($aArray[$i], 8), "=", 3)
        If UBound($aChar, 1) <> 2 Then ContinueLoop
        ConsoleWrite(@TAB & '$sString = StringReplace($sString,' & 'ChrW(' & AscW($aChar[0]) & '), "' & $aChar[1] & '")' & @CRLF)
    Next
    ConsoleWrite("EndFunc" & @CRLF & @CRLF)
EndFunc

_GenerateConverterFunction("characters.txt")

i dont know how to make above script work,,thats my whole problem

i tried to copy above script to notepad, save as .au3, and then convert it to .exe, but nothing happened

what should i do? can anyone explain step by step please

here what i am planning, i know that the best thing, if it possible to make the .exe like google translate appearance. like this

 

Spoiler

1817552094_googletranslate.thumb.png.93757be1b380b4d19e4e0eb7e9ebbdc5.png


so, there are two side (two box), the left side for original text, and the next side is transliterated (replaced letter - in example д it will turn it into letter d)

in example, 

i put this on the left box (original sentences), 
"Çré Gopäla Guru Gosvämé"

so after conversion, it should displayed in the right box like this:

Spoiler

1841784820_gambar2.png.38721a936d966622242e150658681d13.png

that was i am planning, GUI box with such function.

 

but if it difficult, i have made a plan b. Such easier thing like this:
 

its doesnt matter. if the gui box is there or not, or we just need to predefined the original text name and put in on the same location with the .exe file in order that file be processed
like this:
 

Spoiler

converter.png.b785eca64fc9903b04d1fb2b66c2182a.png

note :

1.filename.txt is the original file
2.converter.exe is the extension created by autoitscript.exe, the converting program
3.characters.exe, is the predefined letter replacement (image sample attached below)

so just a simple function/script to do this.

or another alternative like this,

1.when the application is run, it will ask, the script will ask, where is the original text to be transliterated (the location of file), so when we open the .exe, we need to fill or browse the original file first. 
2.then we do the same for the destination of output file
3.of course we already predesignated the settings for character changes like this
 

Spoiler

Characters.txt


Ё=YO
Ж=ZH
Й=Y'
Х=KH
Ц=TC
Ч=CH
Щ=SHC
Ш=SH
Э=E'
Ю=YU
Я=YA
А=A
Б=B
В=V
Г=G
Д=D
Е=E
З=Z
И=I
К=K
Л=L
М=M
Н=N
О=O
П=P
Р=R
С=S
Т=T
У=U
Ф=F
Ъ='
Ы=Y
Ь='
ё=yo
ж=zh
й=y'
х=kh
ц=tc
ч=ch
щ=shc
ш=sh
э=e'
ю=yu
я=ya
а=a
б=b
в=v
г=g
д=d
е=e
з=z
и=i
к=k
л=l
м=m
н=n
о=o
п=p
р=r
с=s
т=t
у=u
ф=f
ъ='
ы=y
ь='
 

so according string replacement in characters.txt, the conversion will be done.

so please anyone can help?

Thanks in advance

Link to comment
Share on other sites

You'll need the beta version of AutoIt to run this code sample:

Local $a = FileReadToArray("characters.txt")
Local $sAu3 = "Local $mConv[]" & @CRLF
For $s In $a
    $sAu3 &= StringRegExpReplace($s, "([^=])=(.*)", '$mConv["$1"] = "$2"' & @CRLF)
Next
FileDelete("conv.au3")
FileWrite("conv.au3", $sAu3)

#include "conv.au3"

Local $sIn = "Привет, безумный мир!"
Local $sOut = _Convert($sIn)
ConsoleWrite($sout)

Func _Convert($s)
    Local $a = StringSplit($s, "", 3)
    Local $t
    For $c In $a
        If MapExists($mConv, $c) Then
            $t &= $mConv[$c]
        Else
            $t &= $c
        EndIf
    Next
    Return $t
EndFunc

 

Edited by jchd

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)

Link to comment
Share on other sites

1 hour ago, jchd said:

You'll need the beta version of AutoIt to run this code sample:

Local $a = FileReadToArray("characters.txt")
Local $sAu3 = "Local $mConv[]" & @CRLF
For $s In $a
    $sAu3 &= StringRegExpReplace($s, "([^=])=(.*)", '$mConv["$1"] = "$2"' & @CRLF)
Next
FileDelete("conv.au3")
FileWrite("conv.au3", $sAu3)

#include "conv.au3"

Local $sIn = "Привет, безумный мир!"
Local $sOut = _Convert($sIn)
ConsoleWrite($sout)

Func _Convert($s)
    Local $a = StringSplit($s, "", 3)
    Local $t
    For $c In $a
        If MapExists($mConv, $c) Then
            $t &= $mConv[$c]
        Else
            $t &= $c
        EndIf
    Next
    Return $t
EndFunc

 

i have try open this using autoit beta
but there are several error

Spoiler

1283963615_gambarerror.thumb.png.8c066447f11e07ebd98873b67498a119.png


and this part seems not working

Local $sIn = "Привет, безумный мир!"
Local $sOut = _Convert($sIn)
ConsoleWrite($sout)
Local $s
Func _Convert($s)
    Local $a = StringSplit($s, "", 3)
    Local $t
    For $c In $a
        If MapExists($mConv, $c) Then
            $t &= $mConv[$c]
        Else
            $t &= $c
        EndIf
    Next
    Return $t
EndFunc

after i run the script this is produced, inside conv.au3

Spoiler
Local $mConv[]
$mConv["Ё"] = "YO"
$mConv["Ж"] = "ZH"
$mConv["Й"] = "Y'"
$mConv["Х"] = "KH"
$mConv["Ц"] = "TC"
$mConv["Ч"] = "CH"
$mConv["Щ"] = "SHC"
$mConv["Ш"] = "SH"
$mConv["Э"] = "E'"
$mConv["Ю"] = "YU"
$mConv["Я"] = "YA"
$mConv["А"] = "A"
$mConv["Б"] = "B"
$mConv["В"] = "V"
$mConv["Г"] = "G"
$mConv["Д"] = "D"
$mConv["Е"] = "E"
$mConv["З"] = "Z"
$mConv["И"] = "I"
$mConv["К"] = "K"
$mConv["Л"] = "L"
$mConv["М"] = "M"
$mConv["Н"] = "N"
$mConv["О"] = "O"
$mConv["П"] = "P"
$mConv["Р"] = "R"
$mConv["С"] = "S"
$mConv["Т"] = "T"
$mConv["У"] = "U"
$mConv["Ф"] = "F"
$mConv["Ъ"] = "'"
$mConv["Ы"] = "Y"
$mConv["Ь"] = "'"
$mConv["ё"] = "yo"
$mConv["ж"] = "zh"
$mConv["й"] = "y'"
$mConv["х"] = "kh"
$mConv["ц"] = "tc"
$mConv["ч"] = "ch"
$mConv["щ"] = "shc"
$mConv["ш"] = "sh"
$mConv["э"] = "e'"
$mConv["ю"] = "yu"
$mConv["я"] = "ya"
$mConv["а"] = "a"
$mConv["б"] = "b"
$mConv["в"] = "v"
$mConv["г"] = "g"
$mConv["д"] = "d"
$mConv["е"] = "e"
$mConv["з"] = "z"
$mConv["и"] = "i"
$mConv["к"] = "k"
$mConv["л"] = "l"
$mConv["м"] = "m"
$mConv["н"] = "n"
$mConv["о"] = "o"
$mConv["п"] = "p"
$mConv["р"] = "r"
$mConv["с"] = "s"
$mConv["т"] = "t"
$mConv["у"] = "u"
$mConv["ф"] = "f"
$mConv["ъ"] = "'"
$mConv["ы"] = "y"
$mConv["ь"] = "'"

so characters.txt is there, which like dictionary, list converting words
i consider, "conv.au3" as out put
then where is the part for importing the input text?

like this, input.txt

with example text, "english word doesnt change, only this word should change (latin word), this one should be converted -  ЁЖЙХЦЧЩ"

then after the script run, it should be this written on "conv.au3"

the result will be like tihs, "english word doesnt change, only this word should change (latin word), this one should be converted - YOZHY'KHTCCHSHC"

following this characters.txt
Ё=YO
Ж=ZH
Й=Y'
Х=KH
Ц=TC
Ч=CH
Щ=SHC
Ш=SH
Э=E'
Ю=YU
Я=YA
А=A
Б=B
В=V
Г=G
Д=D

i hope you understand what i mean, so every single letter in input.txt is converted according to listed letter/character from "characters.txt"
so if there is letter match with the letter listed in "characters.txt" it must be converted become the letter after "=", i.e Б=B, then "Б" must be replaced with "B", and so on.
while other letter which not listed remain the same.

 

 

 

Link to comment
Share on other sites

This is a demo snippet, not supposed to be compiled nor real-world.

Also I expect source code to be UTF8, as should be the default.

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)

Link to comment
Share on other sites

1 minute ago, Earthshine said:

your errors state COULD NOT OPEN INPUT FILE so it can't find conv.au3

yes but it somehow done when i use AutoIT script to exe converter, now the other problem is..my desired script is not yed solved

so i wanted to convert certain predefined letter from a text to others,

i think there is misunderstanding here

this what i am planned to make

308145470_gambarattach1.thumb.png.9f7e486d507c2982dbec5ea6db7f9c12.png

 

2067489221_gambarattach2.thumb.png.df5ab28a1c7bdc63d8c92c37fbd5432b.png

 

so there is configurable text, name characters.txt where i listed, some letter or words. while latter when the script run, all match text must be converted accordingly

in example like above, even if there is word, "Rädhä" maybe replaced to "Radha", not only letter but also word, so the list like this
 

characters.txt
 

Spoiler

ä = a

Ç=S

é=i

ä = a

ö=t

ä = a

ä = a

ü=u

ë=n

ò=d

Rädhä=Radha

Kåñëa=Krsna

i hope my idea is clear..please help

 

Link to comment
Share on other sites

so the example of input.txt is like article, like this

 

Spoiler

the next day, when Vijaya Kumära and Vrajanätha had honored prasäda, they again went to Çré Rädhä-Känta Maöha, arriving just after midday. Çré Gopäla Guru Gosvämé had also honored mahä-prasäda, and was waiting for them. Çré Dhyänacandra Gosvämé was sitting by his side writing Upäsanä- paddhati (The Procedures for Worship). At that time, Çré Guru Gosvämé’s appearance was most remarkable. He was attired in the dress of a sannyäsé, his forehead was marked with ürddhva- puëòra tilaka.

after processed, coverted, the result, output.txt should be like this

 

Spoiler

the next day, when Vijaya Kumara and Vrajanatha had honored prasada, they again went to Sri Radha-Kanta Matha, arriving just after midday. Sri Gopala Guru Gosvami had also honored mahä-prasada, and was waiting for them. Sri Dhyanacandra Gosvami was sitting by his side writing Upasana- paddhati (The Procedures for Worship). At that time, Sri Guru Gosvami’s appearance was most remarkable. He was attired in the dress of a sannyasi, his forehead was marked with urddhva- pundra tilaka.

so every romanian transliteration  letter (or any words mention in characters.exe) should be replaced as we set up in character.exe above

Link to comment
Share on other sites

You really should try to understand how my snippet works and show some effort to write your own code. If/when you hit a concrete block come back, show what you have and how it doesn't work and you'll get all the help you need.

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)

Link to comment
Share on other sites

1 minute ago, jchd said:

You really should try to understand how my snippet works and show some effort to write your own code. If/when you hit a concrete block come back, show what you have and how it doesn't work and you'll get all the help you need.

yes, i mean my input, should be taken from .txt file called input.txt

and then, like i am explain above, there is special letter / words should be replaced according to list in characters.txt

so the script run looping, finding the matching letter/words from input.txt

yes, please tell me how to finding matching words/letter from input.txt

and this is also not working 
 

Local $sIn = "ürddhva- puëòra tilaka"
Local $sOut = _Convert($sIn)
ConsoleWrite($sout)
Local $s
Func _Convert($s)
    Local $a = StringSplit($s, "", 3)
    Local $t
    For $c In $a
        If MapExists($mConv, $c) Then
            $t &= $mConv[$c]
        Else
            $t &= $c
        EndIf
    Next
    Return $t
EndFunc

where is it printed?, where is the output, i dont have any idea to write the script, i need more example from you

Link to comment
Share on other sites

  • Solution

My first steps would be:

1. Right click on an empty space on the desktop

2. New AutoIt v3 Script

3. Right Click on the created new file

4. Edit

5. Paste a simple example like this and save

#include <File.au3>
#include <MsgBoxConstants.au3>

Local $sFind = "д"
Local $sReplace = "d"
Local $sFileName = "test.txt"

Local $iRetval = _ReplaceStringInFile($sFileName, $sFind, $sReplace)
If $iRetval = -1 Then
    MsgBox($MB_SYSTEMMODAL, "ERROR", "The pattern could not be replaced in file: " & $sFileName & " Error: " & @error)
    Exit
Else
    MsgBox($MB_SYSTEMMODAL, "INFO", "Found " & $iRetval & " occurances of the pattern: " & $sFind & " in the file: " & $sFileName)
EndIf

6. Create a text file in same location as the script: test.txt

д some text д more text д

7. Return to the SciTe Editor

8. Place the cursor on the name of some function and press F1 for HELP File (_ReplaceStringInFile in the example above)

9. Press F5 for running the script

10. Repeat again and again: HELP FILE / simple examples for functions / Test ...

Link to comment
Share on other sites

  • Moderators

@subuddhi glad you were able to solve your problem. In the future, please just hit the reply button rather than Quoting what everyone says, it pads the thread and makes it difficult to follow. Also, we all know what we said (we were there when we said it! :) )

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

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