Jump to content

[i am completely beginner] I have question


Go to solution Solved by robertocm,

Recommended Posts

Posted

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
Expand  

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

 

  Reveal hidden contents


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:

  Reveal hidden contents

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:
 

  Reveal hidden contents

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
 

  Reveal hidden contents

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

so please anyone can help?

Thanks in advance

Posted (edited)

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
  Reveal hidden contents

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)

Posted
  On 6/1/2021 at 12:31 PM, 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

 

Expand  

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

  Reveal hidden contents


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

  Reveal hidden contents

 

Posted (edited)

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

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Posted

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.

  Reveal hidden contents

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)

Posted
  On 6/1/2021 at 2:52 PM, Earthshine said:

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

Expand  

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
 

  Reveal hidden contents

i hope my idea is clear..please help

 

Posted

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

 

  Reveal hidden contents

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

 

  Reveal hidden contents

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

Posted

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.

  Reveal hidden contents

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)

Posted
  On 6/1/2021 at 3:29 PM, 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.

Expand  

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

  • Solution
Posted

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 ...

  • Moderators
Posted

@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!

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
  • Recently Browsing   0 members

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