View Single Post
Old 04-10-2008, 03:10 PM   #5
Playbahnosh
The Peacemaker
 
Playbahnosh's Avatar


 
Join Date: Apr 2005
Location: Veszprem, Hungary
Posts: 353
Send a message via MSN to Playbahnosh
Default

If only I knew how to program in Delphi7

If I knew any programming or scripting languages that well, I would've done it myself, but sadly, I'm still only learning them, and the most complicated programs I can write are either display colored lines on the screen, or calculate something in the console window. Manipulating strings and files, and working with dense arrays are still beyond my abilities at this time. I COULD write the pseudo-code for the script/program, but I can't program it myself.

I think a sequential algorithm would work:

Code:
OPEN file
X=0
IF search string "-->" returns result
   THEN:
       move pointer to location
       go down one line
   ELSE:
      msg: "Wrong file"
      END PROGRAM
END IF
REPEAT UNTIL X=1
   IF search string "-->" returns result
      THEN:
         move pointer to location
         go down one line
         record location to variable SP
            IF search string "-->" returns result
               THEN:
                  move pointer to location
                  go down one line
                     REPEAT UNTIL encountering an empty line
                        record actual line to array L
                        DELETE actual line
                     END
                  move pointer to location SP
                     REPEAT UNTIL encountering an empty record in array L
                         insert respective line from array L to this location
                         new line
                      END
               ELSE:
                  END PROGRAM
            END IF
      ELSE:
         X=1
   END IF
END
SAVE file
CLOSE file
msg: "finished"
END PROGRAM
It's just an amateur sketch, but it might work...
__________________
The Master of Light and Darkness

"Don't fight the bad things in life! Find the good one! They are everywhere! Don't spend your life fighting for goals you can never reach! Live for the moment!"


BEWARE: I'm using the forums as a personal blog!
Playbahnosh is offline                         Send a private message to Playbahnosh
Reply With Quote