forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


REM/unREM tool for VDS editor

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code
View previous topic :: View next topic  
Author Message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Mon Dec 09, 2002 10:22 am    Post subject: REM/unREM tool for VDS editor Reply with quote

This one can help you insert/remove REM statements into/from multiple lines in your source files.
For that extra convenience Wink

First of all, you need to compile it into an EXE (you should name it something like REM-UNREM.exe)
and put it in your VDS Tools directory.
Then you can select a number of lines in your VDS editor and choose Tools -> REM-UNREM in
the editor menu line.
The util will now grab the lines selected, make a REM toggle (i.e. normal lines will have a REM
command inserted, and lines being REMed already will have it removed). Finally the results will
be pasted back into the editor, overwriting the lines selected.

Hints:
Don't do anything in the editor, while REM-UNREM is working.
Select only full lines.
Preferably the carriage return of the last line selected should be included for best results.

Greetz
Dr. Dread

Code:

  title REM/unREM    .. by Dr. Dread
  dialog CREATE,REM/unREM,-1,0,0,0,ONTOP
  option DECIMALSEP,"."
  REM Type here the 'style' you want (REM, rem, Rem etc.)
  %%REM = REM
  REM Grab ID of VDS editor window
  %W = @winactive(I)

  list create,1
  clipboard CLEAR
  window SEND,%W,@CTRL(C)
  REM Wait for Clipboard. If you get false 'empty' readings - then adjust timings here
  wait .3
  list paste,1
  wait .1

  REM Check if nothing was copied to the clipboard
  if @null(@item(1))
    info Nothing seems to be selected
    stop
  end
 
  list create,2
  repeat
    %%line = @next(1)
    REM Handle lines with only REM
    if @equal(@trim(%%line),"rem")
      list add,2,""
     goto xloop
    end
    REM Check if line is REMed already
    if @equal(@substr(@trim(%%line),1,4),"rem ")
      list add,2,@strdel(%%line,@pos("rem ",%%line),@sum(@pos("rem ",%%line),3))
    else
   REM If not REMed, then insert REM after indentations
      %%dummy = 0
      %%spacer = 1
      repeat
        %%dummy = @succ(%%dummy)
        %%char = @substr(%%line,%%dummy,)
        if @equal(%%char," ")@equal(%%char,@tab())
          %%spacer = 1
        else
          %%spacer = 0
        end
      until @equal(%%spacer,0)
      list add,2,@strins(%%line,%%dummy,%%REM" ")
    end
   :xloop
  until @equal(@index(1),@count(1))

  list copy,2
  list close,1
  list close,2
  wait .2
  REM Copy back to editor
  window SEND,%W,@CTRL(V)


EDIT: Removed a 'list savefile' command, that was there only for debugging.

EDIT2: Change to work with VDS5 also. Change to handle lines that contain a REM statement only.

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing


Last edited by Dr. Dread on Wed Oct 15, 2003 10:28 am; edited 5 times in total
Back to top
View user's profile Send private message
marty
Professional Member
Professional Member


Joined: 10 May 2001
Posts: 789

PostPosted: Mon Dec 09, 2002 1:22 pm    Post subject: Reply with quote

Excellent, too seconds and it was in my tools folder!

Thats something very practical!


Thanks
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Mon Dec 09, 2002 1:41 pm    Post subject: Reply with quote

Good. Glad ya like it. I thought it might come in handy for others who, like me, have spent
lots of time adding and removing REM from script lines during testing and debugging.

Edited the code a tiny bit, as I had left a savefile command that I originally used for
debugging the script.

Greetz
Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Mac
Professional Member
Professional Member


Joined: 08 Jul 2000
Posts: 1585
Location: Oklahoma USA

PostPosted: Mon Dec 09, 2002 1:58 pm    Post subject: Reply with quote

Nice idea Dread, Smile

I usually stick in a goto NEXT statement and
a NEXT label to skip multiple lines... Wink

Cheers, Mac Smile

_________________
VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
Back to top
View user's profile Send private message Send e-mail
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Fri Aug 01, 2003 7:44 am    Post subject: Reply with quote

Source code edited to work correctly with VDS5 and to handle lines containing a REM statement only..

Greetz
Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Fri Aug 01, 2003 2:18 pm    Post subject: Reply with quote

Nice one Very Happy
_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript 3 Source Code All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group