Reading sign keys inverted.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • RapD
    Forum Member
    • Jul 2005
    • 50

    Reading sign keys inverted.

    Hello.
    I'm make my software to read \ write a txt file from a Input to a specific folder.

    How can i make the letters "!@#$%^&*()_+.," save in the TXT file in inverted?

    I want to make something like this:
    I write in the input the text: Hello!
    And its save the TXT file like this: !Hello
  • Corey
    Indigo Rose Staff Alumni
    • Aug 2002
    • 9745

    #2
    Hi. Well I can help by describing the method, but I'm sorry I don't have time to provide an example right now... Anyhow you would want to:

    1. Extract all characters from your "special character" pool from the main text block into a table (array), making sure to also record which position each character was in using a parallel table.

    2. Reverse the order of table containing your special characters.

    3. Re-insert those characters back into the main text block according to the positions recorded in step 1.

    Hope that helps.

    Comment

    • RapD
      Forum Member
      • Jul 2005
      • 50

      #3
      Sound great but i dont knew how..
      I hope that you give me a simple example when you have the time :yes

      Comment

      • Corey
        Indigo Rose Staff Alumni
        • Aug 2002
        • 9745

        #4
        Let me see what I can come up with... :yes

        Comment

        • Corey
          Indigo Rose Staff Alumni
          • Aug 2002
          • 9745

          #5
          Hi. OK here's a project which will reverse the order of the characters from a character pool you enter, within any string you enter. Bear in mind I only tested it a little bit. The actions are all on the button's OnClick event. This is just one possible way of doing it, and my code is not as elegant as it could be but I wrote it so that it would be obvious what's going on at a glance. Note that I didn't set it up to clear the fields, etc. so you have to restart it each try to be sure it's clearing everything out and working 100%. Sorry, I was in a rush.

          Hope that helps. :yes
          Attached Files

          Comment

          • RapD
            Forum Member
            • Jul 2005
            • 50

            #6
            Corey, i write in the "Enret Text" "Hello!"
            I wirite in the "Enter Characters To Reverse:" "!", i click on the button and its don't working.
            The result come out the same text i was writing.

            Comment

            • Corey
              Indigo Rose Staff Alumni
              • Aug 2002
              • 9745

              #7
              Well sure, you didn't put anything in for it to reverse the exclamation point with. It only reverses the characters from the pool. Add an "o" to the pool.

              If you are looking for a script which looks for words which end in special characters and then flips those characters to the other side of the word, that's a different thing. But this example will get you started on the path to creating that nonetheless. The same general flow applies, it's quite easy once you give it a try. :yes

              Comment

              • RapD
                Forum Member
                • Jul 2005
                • 50

                #8
                I mean for every end of the line "if" the user write the one of the letters "!@#$^&*..." so it be like this:

                in the end of! the line!
                !in the end of! the line

                Comment

                • Corey
                  Indigo Rose Staff Alumni
                  • Aug 2002
                  • 9745

                  #9
                  In the string, "in the end of! the line!" how would you know which exclamation point is supposed to be "the end of the line"?

                  Comment

                  • Worm
                    Indigo Rose Customer
                    • Jul 2002
                    • 3971

                    #10
                    Maybe this'll help
                    Code:
                    tblCatchChars = {"!","@","#","$","%","^","&","*","(",")","_","+",".",","}
                    tblTXTFile = TextFile.ReadToTable("Autoplay\\Docs\\test.txt")
                    for lines = 1, Table.Count(tblTXTFile) do
                    	for chars=1, Table.Count(tblCatchChars) do
                    		if String.Right(tblTXTFile[lines], 1) == tblCatchChars[chars] then
                    			tblTXTFile[lines] = tblCatchChars[chars] .. String.Left(tblTXTFile[lines], String.Length(tblTXTFile[lines]) -1)
                    		end
                    	end
                    end
                    
                    txtOut = Table.Concat(tblTXTFile, "\r\n", 1, Table.Count(tblTXTFile))
                    
                    Dialog.Message("Result", txtOut)

                    Comment

                    • RapD
                      Forum Member
                      • Jul 2005
                      • 50

                      #11
                      Cool! many thanks!
                      can you make it for me to all of the marks like this:

                      magfgfg%#@!
                      %#@!magfgfg

                      Comment

                      • Corey
                        Indigo Rose Staff Alumni
                        • Aug 2002
                        • 9745

                        #12
                        Hi. Sorry I can't build it, but this thread has a bunch of great stuff to help you get started, and I'll be happy to assist you in correcting your script as you go along. I encourage you to get in there and give it a try. It's fun! If you have any questions as you are writing your first script please feel free to ask and I'll be happy to assist.

                        Here's some free video lessons to help you get started with AMS:

                        Comment

                        • Intrigued
                          Indigo Rose Customer
                          • Dec 2003
                          • 6138

                          #13
                          I agree with Corey (and this goes for pretty much anything in life)... give it a serious try. Then if you have a problem show us the code area or the project (or a mockup of the project) and we will help to try and get it working for you.

                          :yes
                          Intrigued

                          Comment

                          Working...
                          X