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 


[Open Source]: Pre-compiler
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript Open Source Projects
View previous topic :: View next topic  
Author Message
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Wed Mar 05, 2003 4:09 pm    Post subject: [Open Source]: Pre-compiler Reply with quote

You can use this code to shorten your source code before you compile it. If you have a large script, it will be about 30% smaller this way...

Just check it out. Please post your bugs, cause I couldn´t implent all dlls....

Code:
rem Create a dialog first, or @filedlg() will not work...
dialog create,Pre-compiler
title @dlgtext()

%%file = @filedlg(*.dsc)
if @not(@file(%%file))@not(@ok())
  exit
  end

list create,1
list loadfile,1,%%file

list create,2

%z = 0

repeat
list add,2,@trim(@item(1,%z))
%z = @succ(%z)
until @equal(%z,@count(1))

list clear,1
list assign,1,2
list clear,2

%z = 0

repeat
%%item = @item(1,%z)

%%command = @substr(%%item,1,3)

if @not(@equal(@pos(@chr(32),%%item),0))
  if @not(@equal(@pos(@chr(44),%%item),0))
    %%subcommand = @substr(%%item,@succ(@pos(@chr(32),%%item)),@pred(@pos(@chr(44),%%item)))
   else
   %%subcommand = @substr(%%item,@succ(@pos(@chr(32),%%item)),@len(%%item))
   end
  else
  %%subcommand =
  end

if @not(@equal(@pos(@chr(44),%%item),0))
  %%parameters = @substr(%%item,@succ(@pos(@chr(44),%%item)),@len(%%item))
  else
  %%parameters =
  end

if @equal(@substr(%%item,1,1),":")@equal(@substr(%%item,1,1),"%")
  %%pass = true
  end

rem - BEEP -
if @equal(%%command,BEE)
%%com = true
  %%command = BE
  end
rem - BINFILE -
if @equal(%%command,BIN)
%%com = true
  %%command = BI
  if @equal(%%subcommand,OPEN)
    %%subcommand = O
    end
  if @equal(%%subcommand,CLOSE)
    %%subcommand = C
    end
  if @equal(%%subcommand,SEEK)
    %%subcommand = S
    end
  if @equal(%%subcommand,WRITE)
    %%subcommand = W
    end
  end
rem - CLIPBOARD -
if @equal(%%command,CLI)
%%com = true
  %%command = C
  if @equal(%%subcommand,APPEND)
    %%subcommand = AP
   end
  if @equal(%%subcommand,CLEAR)
    %%subcommand = C
   end
  if @equal(%%subcommand,SET)
    %%subcommand = S
   end
  end
rem - DDE -
if @equal(%%command,DDE)
%%com = true
  %%command = DD
  if @equal(%%subcommand,LINK)
    %%subcommand = L
   end
  if @equal(%%subcommand,EXECUTE)
    %%subcommand = E
   end
  if @equal(%%subcommand,POKE)
    %%subcommand = P
   end
  if @equal(%%subcommand,TERMINATE)
    %%subcommand = T
   end
  end
rem - DIALOG -
if @equal(%%command,DIA)
%%com = true
  %%command = D
  if @equal(%%subcommand,ADD)
    %%subcommand = AD
    end
  if @equal(%%subcommand,CLEAR)
    %%subcommand = CL
    end
  if @equal(%%subcommand,CLEARSEL)
    %%subcommand = CLEARS
    end
  if @equal(%%subcommand,CLOSE)
    %%subcommand = CLO
    end
  if @equal(%%subcommand,CREATE)
    %%subcommand = CR
    end
  if @equal(%%subcommand,CURSOR)
    %%subcommand = CUR
    end
  if @equal(%%subcommand,DISABLE)
    %%subcommand = DI
    end
  if @equal(%%subcommand,ENABLE)
    %%subcommand = EN
    end
  if @equal(%%subcommand,FOCUS)
    %%subcommand = F
    end
  if @equal(%%subcommand,HIDE)
    %%subcommand = HI
    end
  if @equal(%%subcommand,POPUP)
    %%subcommand = POP
    end
  if @equal(%%subcommand,SELECT)
    %%subcommand = SEL
    end
  if @equal(%%subcommand,SET)
    %%subcommand = S
    end
  if @equal(%%subcommand,SETPOS)
    %%subcommand = SETP
    end
  if @equal(%%subcommand,SHOW)
    %%subcommand = SH
    end
  if @equal(%%subcommand,SHOWMODAL)
    %%subcommand = SHOWM
    end
  if @equal(%%subcommand,TITLE)
    %%subcommand = T
    end
  end
rem - DIRECTORY -
if @equal(%%command,DIR)
%%com = true
  %%command = DIRE
  if @equal(%%subcommand,CHANGE)
    %%subcommand = C
    end
  if @equal(%%subcommand,CREATE)
    %%subcommand = CR
    end
  if @equal(%%subcommand,DELETE)
    %%subcommand = D
    end
  if @equal(%%subcommand,RENAME)
    %%subcommand = REN
    end
  end
rem - ELSE / ELSIF -
if @equal(%%command,ELS)
%%com = true
  if @equal(@substr(%%item,1,4),ELSE)
    %%command = EL
   else
   %%command = ELSIF
   end
  end
rem - END -
if @equal(%%command,END)
%%com = true
  %%command = EN
  end
rem - EXIT / EXITWIN -
if @equal(%%command,EXI)
%%com = true
  if @equal(@substr(%%item,1,5),EXITW)
    %%command = EXITW
   if @equal(%%subcommand,SHUTDOWN)
     %%subcommand = SHU
     end
   if @equal(%%subcommand,REBOOT)
     %%subcommand = REB
     end
   if @equal(%%subcommand,LOGOFF)
     %%subcommand = LOG
     end
   if @equal(%%subcommand,POWEROFF)
     %%subcommand = POW
     end
   if @equal(%%subcommand,FORCE)
     %%subcommand = FOR
     end
   else
   %%command = EX
   end
  end
rem - EXTERNAL -
if @equal(%%command,EXT)
  %%com = true
  if @equal(@substr(%%item,1,4),EXTE)
   %%command = EXT
   else
   %%command = EXTLIST
   end
  end
rem - FILE -
if @equal(%%command,FIL)
%%com = true
  %%command = FIL
  if @equal(%%subcommand,COPY)
    %%subcommand =C
   end
  if @equal(%%subcommand,DELETE)
    %%subcommand = D
   end
  if @equal(%%subcommand,RENAME)
    %%subcommand = R
   end
  if @equal(%%subcommand,SETDATE)
    %%subcommand = SETD
   end
  if @equal(%%subcommand,SETATTR)
    %%subcommand = SETA
   end
  end
rem - FONT -
if @equal(%%command,FON)
%%com = true
  %%command = FON
  if @equal(%%subcommand,ADD)
    %%subcommand = AD
    end
  if @equal(%%subcommand,REMOVE)
    %%subcommand = RE
   end
  end
rem - GOSUB -
if @equal(%%command,GOS)
%%com = true
  %%command = G
  end
rem - GOTO -
if @equal(%%command,GOS)
%%com = true
  %%command = GOT
  end
rem - IF -
if @equal(%%command,IF )
%%com = true
  %%command = I
  end
rem - INFO -
if @equal(%%command,INF)
%%com = true
  %%command = IN
  end
rem - INIFILE -
if @equal(%%command,INI)
%%com = true
  %%command = INI
  if @equal(%%subcommand,OPEN)
    %%subcommand = O
   end
  if @equal(%%subcommand,WRITE)
    %%subcommand = W
   end
  end
rem - LINK -
if @equal(%%command,LIN) 
%%com = true
  %%command = LIN
  %%subcommand = CREATE
  end
rem - LIST -
if @equal(%%command,LIS)
%%com = true
  %%command = LI
  if @equal(%%subcommand,ADD)
    %%subcommand =ADD
   end
  if @equal(%%subcommand,APPEND)
    %%subcommand = AP
   end
  if @equal(%%subcommand,ASSIGN)
    %%subcommand = AS
   end
  if @equal(%%subcommand,CLEAR)
    %%subcommand = CLE
   end
  if @equal(%%subcommand,CLOSE)
    %%subcommand = CL
   end
  if @equal(%%subcommand,COPY)
    %%subcommand = CO
   end
  if @equal(%%subcommand,CREATE)
    %%subcommand = C
   end
  if @equal(%%subcommand,DELETE)
    %%subcommand = DE
   end
  if @equal(%%subcommand,INSERT)
    %%subcommand = IN
   end
  if @equal(%%subcommand,PASTE)
    %%subcommand = PA
   end
  if @equal(%%subcommand,PUT)
    %%subcommand = PU
   end
  if @equal(%%subcommand,REVERSE)
    %%subcommand = REV
   end
  if @equal(%%subcommand,SEEK)
    %%subcommand = S
   end
  if @equal(%%subcommand,DROPFILES)
    %%subcommand = DR
   end
  if @equal(%%subcommand,FILELIST)
    %%subcommand = F
   end
  if @equal(%%subcommand,LOADFILE)
    %%subcommand = LOA
   end
  if @equal(%%subcommand,LOADTEXT)
    %%subcommand = LOADT
   end
  if @equal(%%subcommand,REGKEYS)
    %%subcommand = REG
   end
  if @equal(%%subcommand,REGVALS)
    %%subcommand = REGV
   end
  if @equal(%%subcommand,SAVEFILE)
    %%subcommand = SA
   end
  if @equal(%%subcommand,WINLIST)
    %%subcommand = W
   end
  end
rem - OPTION -
if @equal(%%command,OPT)
%%com = true
  %%command = O
  %%subcommand = @substr(%%subcommand,1,4)
  end
rem - PARSE -
if @equal(%%command,PAR) 
%%com = true
  %%command = PA
  end
rem - PLAY -
if @equal(%%command,PLA)
%%com = true
  %%command = PL
  end
rem - RANDOM -
if @equal(%%command,RAN)
%%com = true
  %%command = RA
  end
rem - REGISTRY
if @equal(%%command,REG)
%%com = true
  %%command = R
  if @equal(%%subcommand,DELETE)
    %%subcommand = D
   end
  if @equal(%%subcommand,WRITE)
    %%subcommand = W
   end
  end
rem - REPEAT -
if @equal(%%command,REP)
%%com = true
  %%command = REP
  end
rem - UNTIL -
if @equal(%%command,UNT)
%%com = true
  %%command = U
  end
rem - RUN - 
if @equal(%%command,RUN)
%%com = true
  rem Don't do anything, because it can be RUN, RUNH, RUNM & RUNZ
  end
rem - SHELL -
if @equal(%%command,SHE)
%%com = true
  %%command = SHE
  end
rem - SHIFT -
if @equal(%%command,SHI)
%%com = true
  %%command = S
  end
rem - STOP -
if @equal(%%command,STO)
%%com = true
  %%command = ST
  end
rem - TASKBAR -
if @equal(%%command,TAS)
%%com = true
  %%command = TA
  end
rem - TIMER -
if @equal(%%command,TIM) 
%%com = true
  %%command = TIM
  if @equal(%%subcommand,START)
    %%subcommand = STA
   end
  if @equal(%%subcommand,STOP)
    %%subcommand = STO
   end
  if @equal(%%subcommand,PAUSE)
    %%subcommand = PAU
   end
  end
rem - TITLE -
if @equal(%%command,TIT)
%%com = true
  %%command = T
  end 
rem - WAIT -
if @equal(%%command,WAI)
%%com = true
  %%command = W
  end
rem - WEND -
if @equal(%%command,WEN)
%%com = true
  %%command = WE
  end
rem - WHILE -
if @equal(%%command,WHI)
%%com = true
  %%command = WH
  end
rem - WARN -
if @equal(%%command,WAR)
%%com = true
  %%command = WAR
  end
rem - WINDOW / WINHELP -
if @equal(%%command,WIN)
%%com = true
if @equal(@substr(%%item,1,4),WIND)
    rem - WINDOW -
    %%command = WI
    if @equal(%%subcommand,ACTIVATE)
      %%subcommand = A
     end
    if @equal(%%subcommand,CLICK)
      %%subcommand = CLI
     end
    if @equal(%%subcommand,CLOSE)
      %%subcommand = CL
     end
    if @equal(%%subcommand,FLASH)
      %%subcommand = F
       end
    if @equal(%%subcommand,HIDE)
      %%subcommand = H
     end
    if @equal(%%subcommand,ICONIZE)
      %%subcommand = IC
     end
    if @equal(%%subcommand,MAXIMZE)
      %%subcommand = M
     end
    if @equal(%%subcommand,NORMAL)
      %%subcommand = NO
     end
    if @equal(%%subcommand,ONTOP)
      %%subcommand = ONT
     end
    if @equal(%%subcommand,POSITION)
      %%subcommand = PO
     end
    if @equal(%%subcommand,SEND)
      %%subcommand = SE
     end
    if @equal(%%subcommand,SETTEXT)
      %%subcommand = SET
     end
   else
   rem - WINHELP -
   %%command = WINH
   end
  end

if @equal(%%pass,true)
  %%pass = false 
   
   rem VARIABLE!
    if @equal(@substr(%%item,1,1),"%")
     %%varname = @substr(%%item,1,@pos(=,%%item))
      end
 
  list add,2,%%item
  else
  if @equal(%%com,true)
    %%com = false
    if @not(@equal(%%parameters,))
      list add,2,%%command %%subcommand@chr(44)%%parameters
      else
      list add,2,%%command %%subcommand
      end
   else
   list add,2,%%item
   end
  end
 
%z = @succ(%z)
until @equal(%z,@count(1))

clipboard set,@text(2)

list savefile,2,@path(%%file)@name(%%file)_compile_ready.dsc

if @ask(Do you want to open the converted file with VDS?)
  shell open,@path(%%file)@name(%%file)_compile_ready.dsc
  end


Edit 1: Changed the repeat loop into an exit...
Edit 2: Removed the EXTLIST/EXTERNAL error and the ELSE problem...


Last edited by Skit3000 on Sun Mar 09, 2003 1:49 pm; edited 2 times in total
Back to top
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Mar 05, 2003 8:42 pm    Post subject: Reply with quote

I like it. Good thing to have in the toolbox. Wink
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1562

PostPosted: Wed Mar 05, 2003 9:46 pm    Post subject: Reply with quote

Not to be negative but this really will just cut down on a few bytes from your compiled exe's, is it really worth saving a few bytes and suffer from lack of readability in your source??
Back to top
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Mar 05, 2003 10:50 pm    Post subject: Reply with quote

Quote:
Not to be negative but this really will just cut down on a few bytes from your compiled exe's, is it really worth saving a few bytes and suffer from lack of readability in your source??


I thought about that and I'd keep a full version of the file, but don't forget
the positive: it might take hackers/crackers longer to read the code of your
application because it's really not that readable to the human eye. Smile

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Wed Mar 05, 2003 10:56 pm    Post subject: Reply with quote

Skit, I have one change for your script:

I think that the code

Code:
repeat
%%file = @filedlg(*.dsc)
until %%file


Should be

Code:
%%file = @filedlg(*.dsc)
if @not(@file(%%file))@not(@ok())
exit
end


So that you have the option to use the 'Cancel' button. Wink

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Thu Mar 06, 2003 2:52 pm    Post subject: Reply with quote

My 2 cents,
I would not use the short versions of the commands and function names in VDS. These may go away if SADE decides to make a command or function from the short version of a command or function...

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Thu Mar 06, 2003 6:44 pm    Post subject: Reply with quote

Well Prakash, it creates a new file which can be opened with another VDS window. It will also be saved under a different filename, so you'll always keep your original code...
Back to top
View user's profile Send private message
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Fri Mar 07, 2003 10:14 pm    Post subject: Reply with quote

great idea skit3000 - it would be great to use just to compile the code

Serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Sat Mar 08, 2003 12:53 pm    Post subject: Reply with quote

Hi Skit3000,

hope you don't mind...i developped an interface to pre-compile code using your algorithm and i added some features to it that i have been wanting to have for some time.

The code below, in addition to your contribution, makes it possible to easily edit the dsp files (used in compilations) + to add the version number, the build number and the date to the code as part of the pre-compiling process.

It also displays the size of the normal code file and that of the code that has been pre-compiled (so you can see the file size saving). I have noticed a gain of around 20%.

Does the code run quicker by having it pre-compiled or does it make no difference - to its speed?

Here's the code:

Code:

rem === This is an interface to support and extend the code that skit3000
rem === put together as a pre-compile program to reduce the size of compiled
rem === exe files.
rem ===                                                                     
rem === My extension essentially enables you to easily edit the dsp file values
rem === so that you can both reduce the size of the compiled program and you
rem === can edit the information to be included with the compiled program at
rem === the same time - hopefully a great time saver.
rem ===                                                                     
rem === Feel free to edit/change this code to suit your needs. Note that some
rem === default values will need to be changed to meet your particular needs.
rem ===                                                                     
rem === Enjoy!
rem ===                                                                     
rem === Serge   

option fieldsep, .
option scale, 96

Title Pre-Compile
  DIALOG CREATE,Pre-Compile,-1,0,668,560
REM *** Modified by Dialog Designer on 10/03/03 - 00:30 ***
  DIALOG ADD,STYLE,UNDERLINE,,,U,,BLUE
  DIALOG ADD,TEXT,TEXT1,10,10,,,VDS File
  DIALOG ADD,EDIT,EDIT1,25,10,180,20
  DIALOG ADD,BUTTON,browse_b,55,40,110,25,Browse
  DIALOG ADD,TEXT,TEXT2,90,10,,,Original EXE File Name
  DIALOG ADD,EDIT,EDIT2,105,10,180,20
  DIALOG ADD,TEXT,TEXT3,140,10,,,File/Product Version and...
  DIALOG ADD,SPIN,SPIN1,160,10,40,22
  DIALOG ADD,SPIN,SPIN2,160,60,40,22
  DIALOG ADD,SPIN,SPIN3,160,110,40,22
  DIALOG ADD,TEXT,TEXT4,140,155,,,...Build
  DIALOG ADD,SPIN,SPIN4,160,160,40,22
  DIALOG ADD,TEXT,TEXT5,200,10,,,Product Name
  DIALOG ADD,EDIT,EDIT3,215,10,180,20
  DIALOG ADD,TEXT,TEXT6,250,10,,,Current Date
  DIALOG ADD,EDIT,EDIT4,265,10,180,20
  DIALOG ADD,TEXT,TEXT7,300,10,,,Company Name,,CLICK,HAND,UNDERLINE
  DIALOG ADD,EDIT,EDIT5,315,10,180,20
  DIALOG ADD,TEXT,TEXT8,350,10,,,Program Description
  DIALOG ADD,EDIT,EDIT6,365,10,180,50,,,MULTI,SCROLL,WRAP
  DIALOG ADD,TEXT,TEXT9,430,10,,,Copyright,,CLICK,HAND,UNDERLINE
  DIALOG ADD,EDIT,EDIT7,444,10,180,40,,,MULTI,SCROLL,WRAP
  DIALOG ADD,TEXT,TEXT10,10,220,,,VDS Code
  DIALOG ADD,LIST,LIST1,30,220,400,440
  DIALOG ADD,BUTTON,compile_b,497,50,100,30,Pre-Compile
  DIALOG ADD,STYLE,PIE_STYLE,,,,YELLOW,RED
  DIALOG ADD,PIECHART,PIECHART1,476,440,62,60,0,,,PIE_STYLE
  DIALOG ADD,TEXT,TEXT11,485,220,,,File:
  DIALOG ADD,TEXT,TEXT12,510,220,,,Pre-Compiled:
  DIALOG ADD,BUTTON,quit_b,484,520,92,46,Quit
  DIALOG ADD,LEVEL,LEVEL1,29,632,24,500,0
  DIALOG ADD,STATUS,STATUS
  DIALOG SHOW
 
  dialog disable, compile_b
  dialog set, piechart1, 100
  dialog set, edit4, @datetime(mmmm yyyy)
  list create, 1

:Evloop
  wait event
  goto @event()

:browse_bBUTTON
  %%dummy = @filedlg(*.dsc,Open...)
 
  if @ok()
  else
      goto evloop
  end
 
  if %%dummy
      %%file = %%dummy
      dialog enable, compile_b
      dialog set, edit1, @name(%%dummy).dsc
    dialog set, status, @path(%%dummy)
   
    rem === loads code ===
    list loadfile, list1, @path(%%dummy)@name(@dlgtext(edit1)).dsc
    %%file_size = @file(%%dummy,z)
    dialog set, text11, File: %%file_size bytes + @count(list1) lines
    dialog set, text12, Pre-Compiled:
   
    dialog set, piechart1, 100
    dialog set, level1, 0
   
    rem === loads values from dsp file ===
    inifile open, @path(%%dummy)@name(@dlgtext(edit1)).dsp
    dialog set, edit5, @iniread(Compiler, CompanyName)
    dialog set, edit2, @iniread(Compiler, OriginalFilename)
    %%file_version = @iniread(Compiler, FileVersion)
    parse "%1;%2;%3;%4", %%file_version
    dialog set, spin1, %1
    dialog set, spin2, %2
    dialog set, spin3, %3
    dialog set, spin4, %4
    dialog set, edit3, @iniread(Compiler, ProductName)
    dialog set, edit6, @iniread(Compiler, FileDescription)
    dialog set, edit7, @iniread(Compiler, LegalCopyright)
  end
  goto evloop
 
:text7CLICK
  rem === default value ===
  dialog set, edit5, Cattle Ramp Software
  goto evloop
 
:text9CLICK
  rem === default value ==
  dialog set, edit7, © Serge M Botans"," All Rights Reserved"," @datetime(mmmm yyyy)
  goto evloop 

:quit_bBUTTON
:Close
  exit

:compile_bBUTTON

rem === update dsp file ===
inifile write, Compiler, CompanyName, @dlgtext(edit5)
inifile write, Compiler, OriginalFilename, @dlgtext(edit2)
inifile write, Compiler, FileVersion, @dlgtext(spin1).@dlgtext(spin2).@dlgtext(spin3).@dlgtext(spin4)
inifile write, Compiler, ProductName, @dlgtext(edit3)
inifile write, Compiler, FileDescription, @dlgtext(edit6)
inifile write, Compiler, ProductVersion, @dlgtext(spin1).@dlgtext(spin2).@dlgtext(spin3).@dlgtext(spin4)
inifile write, Compiler, LegalCopyright, @dlgtext(edit7)

rem === code below is by skit3000 ===
dialog cursor, wait

list clear,1
list loadfile,1,%%file

rem === my added code to update the code with version, build and date ===
list seek, 1, 0
if @greater(@match(1,"%%version ="),0)
   list put, 1, "%%version = "@dlgtext(spin1).@dlgtext(spin2)
else
   list seek, 1, 0
   list insert, 1, "%%version = "@dlgtext(spin1).@dlgtext(spin2)
end

if @greater(@match(1,"%%release ="),0)
   list put, 1, "%%release = "@dlgtext(spin3)
else
   list seek, 1, 1
   list insert, 1, "%%release = "@dlgtext(spin3)
end

if @greater(@match(1,"%%build ="),0)
   list put, 1, "%%build = "@dlgtext(spin4)
else
   list seek, 1, 2
   list insert, 1, "%%build = "@dlgtext(spin4)
end

if @greater(@match(1,"%%date ="),0)
   list put, 1, "%%date = "@dlgtext(edit4)
else
   list seek, 1, 3
   list insert, 1, "%%date = "@dlgtext(edit4)
end

rem === my added code to remove all blank lines and all rem lines ===
list seek, 1, 0
%i = 0
repeat
   list seek, 1, %i
   if @greater(@pos(rem ,@item(1)),0)@null(@trim(@item(1)))
        list delete, 1
     %i = @pred(%i)
     if @greater(%i,0)
         %i = @pred(%i)
     end
   end
   %i = @succ(%i)
   dialog set, level1, @div(@fmul(%i,100),@count(1))
until @equal(%i,@count(1))

rem === code below is by skit3000 ===
list create,2

%z = 0

repeat
list add,2,@trim(@item(1,%z))
%z = @succ(%z)
dialog set, level1, @div(@fmul(%z,100),@count(1))
until @equal(%z,@count(1))

list clear,1
list assign,1,2
list clear,2

%z = 0

repeat
%%item = @item(1,%z)

%%command = @substr(%%item,1,3)

if @not(@equal(@pos(@chr(32),%%item),0))
  if @not(@equal(@pos(@chr(44),%%item),0))
    %%subcommand = @substr(%%item,@succ(@pos(@chr(32),%%item)),@pred(@pos(@chr(44),%%item)))
   else
   %%subcommand = @substr(%%item,@succ(@pos(@chr(32),%%item)),@len(%%item))
   end
  else
  %%subcommand =
  end

if @not(@equal(@pos(@chr(44),%%item),0))
  %%parameters = @substr(%%item,@succ(@pos(@chr(44),%%item)),@len(%%item))
  else
  %%parameters =
  end

if @equal(@substr(%%item,1,1),":")@equal(@substr(%%item,1,1),"%")
  %%pass = true
  end

rem - BEEP -
if @equal(%%command,BEE)
%%com = true
  %%command = BE
  end
rem - BINFILE -
if @equal(%%command,BIN)
%%com = true
  %%command = BI
  if @equal(%%subcommand,OPEN)
    %%subcommand = O
    end
  if @equal(%%subcommand,CLOSE)
    %%subcommand = C
    end
  if @equal(%%subcommand,SEEK)
    %%subcommand = S
    end
  if @equal(%%subcommand,WRITE)
    %%subcommand = W
    end
  end
rem - CLIPBOARD -
if @equal(%%command,CLI)
%%com = true
  %%command = C
  if @equal(%%subcommand,APPEND)
    %%subcommand = AP
   end
  if @equal(%%subcommand,CLEAR)
    %%subcommand = C
   end
  if @equal(%%subcommand,SET)
    %%subcommand = S
   end
  end
rem - DDE -
if @equal(%%command,DDE)
%%com = true
  %%command = DD
  if @equal(%%subcommand,LINK)
    %%subcommand = L
   end
  if @equal(%%subcommand,EXECUTE)
    %%subcommand = E
   end
  if @equal(%%subcommand,POKE)
    %%subcommand = P
   end
  if @equal(%%subcommand,TERMINATE)
    %%subcommand = T
   end
  end
rem - DIALOG -
if @equal(%%command,DIA)
%%com = true
  %%command = D
  if @equal(%%subcommand,ADD)
    %%subcommand = AD
    end
  if @equal(%%subcommand,CLEAR)
    %%subcommand = CL
    end
  if @equal(%%subcommand,CLEARSEL)
    %%subcommand = CLEARS
    end
  if @equal(%%subcommand,CLOSE)
    %%subcommand = CLO
    end
  if @equal(%%subcommand,CREATE)
    %%subcommand = CR
    end
  if @equal(%%subcommand,CURSOR)
    %%subcommand = CUR
    end
  if @equal(%%subcommand,DISABLE)
    %%subcommand = DI
    end
  if @equal(%%subcommand,ENABLE)
    %%subcommand = EN
    end
  if @equal(%%subcommand,FOCUS)
    %%subcommand = F
    end
  if @equal(%%subcommand,HIDE)
    %%subcommand = HI
    end
  if @equal(%%subcommand,POPUP)
    %%subcommand = POP
    end
  if @equal(%%subcommand,SELECT)
    %%subcommand = SEL
    end
  if @equal(%%subcommand,SET)
    %%subcommand = S
    end
  if @equal(%%subcommand,SETPOS)
    %%subcommand = SETP
    end
  if @equal(%%subcommand,SHOW)
    %%subcommand = SH
    end
  if @equal(%%subcommand,SHOWMODAL)
    %%subcommand = SHOWM
    end
  if @equal(%%subcommand,TITLE)
    %%subcommand = T
    end
  end
rem - DIRECTORY -
if @equal(%%command,DIR)
%%com = true
  %%command = DIRE
  if @equal(%%subcommand,CHANGE)
    %%subcommand = C
    end
  if @equal(%%subcommand,CREATE)
    %%subcommand = CR
    end
  if @equal(%%subcommand,DELETE)
    %%subcommand = D
    end
  if @equal(%%subcommand,RENAME)
    %%subcommand = REN
    end
  end
rem - ELSE / ELSIF -
if @equal(%%command,ELS)
%%com = true
  if @equal(@substr(%%item,1,4),ELSE)
    %%command = E
   else
   %%command = ELSIF
   end
  end
rem - END -
if @equal(%%command,END)
%%com = true
  %%command = EN
  end
rem - EXIT / EXITWIN -
if @equal(%%command,EXI)
%%com = true
  if @equal(@substr(%%item,1,5),EXITW)
    %%command = EXITW
   if @equal(%%subcommand,SHUTDOWN)
     %%subcommand = SHU
     end
   if @equal(%%subcommand,REBOOT)
     %%subcommand = REB
     end
   if @equal(%%subcommand,LOGOFF)
     %%subcommand = LOG
     end
   if @equal(%%subcommand,POWEROFF)
     %%subcommand = POW
     end
   if @equal(%%subcommand,FORCE)
     %%subcommand = FOR
     end
   else
   %%command = EX
   end
  end
rem - EXTERNAL -
if @equal(%%command,EXT)
  %%com = true
  if @equal(@substr(%%command,1,4),EXTE)
    %%command = EXT
   else
   %%command = EXTLIST
   end
  end
rem - FILE -
if @equal(%%command,FIL)
%%com = true
  %%command = FIL
  if @equal(%%subcommand,COPY)
    %%subcommand =C
   end
  if @equal(%%subcommand,DELETE)
    %%subcommand = D
   end
  if @equal(%%subcommand,RENAME)
    %%subcommand = R
   end
  if @equal(%%subcommand,SETDATE)
    %%subcommand = SETD
   end
  if @equal(%%subcommand,SETATTR)
    %%subcommand = SETA
   end
  end
rem - FONT -
if @equal(%%command,FON)
%%com = true
  %%command = FON
  if @equal(%%subcommand,ADD)
    %%subcommand = AD
    end
  if @equal(%%subcommand,REMOVE)
    %%subcommand = RE
   end
  end
rem - GOSUB -
if @equal(%%command,GOS)
%%com = true
  %%command = G
  end
rem - GOTO -
if @equal(%%command,GOS)
%%com = true
  %%command = GOT
  end
rem - IF -
if @equal(%%command,IF )
%%com = true
  %%command = IF
  end
rem - INFO -
if @equal(%%command,INF)
%%com = true
  %%command = IN
  end
rem - INIFILE -
if @equal(%%command,INI)
%%com = true
  %%command = INI
  if @equal(%%subcommand,OPEN)
    %%subcommand = O
   end
  if @equal(%%subcommand,WRITE)
    %%subcommand = W
   end
  end
rem - LINK -
if @equal(%%command,LIN) 
%%com = true
  %%command = LIN
  %%subcommand = CREATE
  end
rem - LIST -
if @equal(%%command,LIS)
%%com = true
  %%command = LI
  if @equal(%%subcommand,ADD)
    %%subcommand =ADD
   end
  if @equal(%%subcommand,APPEND)
    %%subcommand = AP
   end
  if @equal(%%subcommand,ASSIGN)
    %%subcommand = AS
   end
  if @equal(%%subcommand,CLEAR)
    %%subcommand = CLE
   end
  if @equal(%%subcommand,CLOSE)
    %%subcommand = CL
   end
  if @equal(%%subcommand,COPY)
    %%subcommand = CO
   end
  if @equal(%%subcommand,CREATE)
    %%subcommand = C
   end
  if @equal(%%subcommand,DELETE)
    %%subcommand = DE
   end
  if @equal(%%subcommand,INSERT)
    %%subcommand = IN
   end
  if @equal(%%subcommand,PASTE)
    %%subcommand = PA
   end
  if @equal(%%subcommand,PUT)
    %%subcommand = PU
   end
  if @equal(%%subcommand,REVERSE)
    %%subcommand = REV
   end
  if @equal(%%subcommand,SEEK)
    %%subcommand = S
   end
  if @equal(%%subcommand,DROPFILES)
    %%subcommand = DR
   end
  if @equal(%%subcommand,FILELIST)
    %%subcommand = F
   end
  if @equal(%%subcommand,LOADFILE)
    %%subcommand = LOA
   end
  if @equal(%%subcommand,LOADTEXT)
    %%subcommand = LOADT
   end
  if @equal(%%subcommand,REGKEYS)
    %%subcommand = REG
   end
  if @equal(%%subcommand,REGVALS)
    %%subcommand = REGV
   end
  if @equal(%%subcommand,SAVEFILE)
    %%subcommand = SA
   end
  if @equal(%%subcommand,WINLIST)
    %%subcommand = W
   end
  end
rem - OPTION -
if @equal(%%command,OPT)
%%com = true
  %%command = O
  %%subcommand = @substr(%%subcommand,1,4)
  end
rem - PARSE -
if @equal(%%command,PAR) 
%%com = true
  %%command = PA
  end
rem - PLAY -
if @equal(%%command,PLA)
%%com = true
  %%command = PL
  end
rem - RANDOM -
if @equal(%%command,RAN)
%%com = true
  %%command = RA
  end
rem - REGISTRY
if @equal(%%command,REG)
%%com = true
  %%command = R
  if @equal(%%subcommand,DELETE)
    %%subcommand = D
   end
  if @equal(%%subcommand,WRITE)
    %%subcommand = W
   end
  end
rem - REPEAT -
if @equal(%%command,REP)
%%com = true
  %%command = REP
  end
rem - UNTIL -
if @equal(%%command,UNT)
%%com = true
  %%command = U
  end
rem - RUN - 
if @equal(%%command,RUN)
%%com = true
  rem Don't do anything, because it can be RUN, RUNH, RUNM & RUNZ
  end
rem - SHELL -
if @equal(%%command,SHE)
%%com = true
  %%command = SHE
  end
rem - SHIFT -
if @equal(%%command,SHI)
%%com = true
  %%command = S
  end
rem - STOP -
if @equal(%%command,STO)
%%com = true
  %%command = ST
  end
rem - TASKBAR -
if @equal(%%command,TAS)
%%com = true
  %%command = TA
  end
rem - TIMER -
if @equal(%%command,TIM) 
%%com = true
  %%command = TIM
  if @equal(%%subcommand,START)
    %%subcommand = STA
   end
  if @equal(%%subcommand,STOP)
    %%subcommand = STO
   end
  if @equal(%%subcommand,PAUSE)
    %%subcommand = PAU
   end
  end
rem - TITLE -
if @equal(%%command,TIT)
%%com = true
  %%command = T
  end 
rem - WAIT -
if @equal(%%command,WAI)
%%com = true
  %%command = W
  end
rem - WEND -
if @equal(%%command,WEN)
%%com = true
  %%command = WE
  end
rem - WHILE -
if @equal(%%command,WHI)
%%com = true
  %%command = WH
  end
rem - WARN -
if @equal(%%command,WAR)
%%com = true
  %%command = WAR
  end
rem - WINDOW / WINHELP -
if @equal(%%command,WIN)
%%com = true
if @equal(@substr(%%item,1,4),WIND)
    rem - WINDOW -
    %%command = WI
    if @equal(%%subcommand,ACTIVATE)
      %%subcommand = A
     end
    if @equal(%%subcommand,CLICK)
      %%subcommand = CLI
     end
    if @equal(%%subcommand,CLOSE)
      %%subcommand = CL
     end
    if @equal(%%subcommand,FLASH)
      %%subcommand = F
       end
    if @equal(%%subcommand,HIDE)
      %%subcommand = H
     end
    if @equal(%%subcommand,ICONIZE)
      %%subcommand = IC
     end
    if @equal(%%subcommand,MAXIMZE)
      %%subcommand = M
     end
    if @equal(%%subcommand,NORMAL)
      %%subcommand = NO
     end
    if @equal(%%subcommand,ONTOP)
      %%subcommand = ONT
     end
    if @equal(%%subcommand,POSITION)
      %%subcommand = PO
     end
    if @equal(%%subcommand,SEND)
      %%subcommand = SE
     end
    if @equal(%%subcommand,SETTEXT)
      %%subcommand = SET
     end
   else
   rem - WINHELP -
   %%command = WINH
   end
  end

if @equal(%%pass,true)
  %%pass = false 
   
   rem VARIABLE!
    if @equal(@substr(%%item,1,1),"%")
     %%varname = @substr(%%item,1,@pos(=,%%item))
      end
 
  list add,2,%%item
  else
  if @equal(%%com,true)
    %%com = false
    if @not(@equal(%%parameters,))
      list add,2,%%command %%subcommand@chr(44)%%parameters
      else
      list add,2,%%command %%subcommand
      end
   else
   list add,2,%%item
   end
  end
 
%z = @succ(%z)
dialog set, level1, @div(@fmul(%z,100),@count(1))
until @equal(%z,@count(1))

clipboard set,@text(2)

list savefile,2,@path(%%file)@name(%%file)_compile_ready.dsc
file copy, @path(%%dummy)@name(@dlgtext(edit1)).dsp,@path(%%file)@name(%%file)_compile_ready.dsp

list clear, list1
list assign,list1,2

rem dialog set, edit8, @text(2)
%%new_file_size = @file(@path(%%file)@name(%%file)_compile_ready.dsc ,z)
%%percentage = @div(@fmul(%%new_file_size,100),%%file_size)
dialog set, text12, Pre-Compiled: %%new_file_size bytes (%%percentage%) + @count(list1) lines

dialog set, piechart1, %%percentage

dialog cursor,
list close, 2

if @ask(Do you want to open the converted file with VDS?)
  shell open,@path(%%file)@name(%%file)_compile_ready.dsc
end

goto evloop


EDITED March 10 (added the level bar, changed 2 texts into "hyperlinks" to load default values into edit boxes, program will now also remove all blank lines and all REM lines to acheive even better saving in file size and to reduce the number of lines of code, code is loaded in list box instead of an edit box)

Serge

_________________


Last edited by Serge on Sun Mar 09, 2003 2:35 pm; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sat Mar 08, 2003 6:51 pm    Post subject: Reply with quote

Hi Serge,

What you've done looks real cool! Only one question: what's the use of the 'File Name' editbox?
Back to top
View user's profile Send private message
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Sat Mar 08, 2003 10:31 pm    Post subject: Reply with quote

thanks skit3000 Smile

the FILE NAME edit box is there because when you want to compile a file and you click on the ADD VERSION INFORMATION, there is a field there for the ORIGINAL FILE NAME...not sure why it is there but just for the sake of completeness i have included it in the interface

may be the ORIGINAL FILE NAME is there in case folks want to check to see if someone (other than the author) has changed the name of the file...

feel free to change the code to suit you if you want Smile

Serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Sun Mar 09, 2003 5:53 am    Post subject: Reply with quote

hi skit3000,

i came across some problems with the code for pre-compiling code

- the command EXTERNAL is changed for EXLIST which vds does not recognise

- the combination IF...ELSIF...ELSE...END does not work properly when pre-compiled

- the LIST commands also don't seem to work properly

sorry about that but i tried your code on a program that uses all the above and ran it only to get errors along those lines Sad

could you recheck the substitutions for me please

sorry about that

Serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sun Mar 09, 2003 12:59 pm    Post subject: Reply with quote

Hi Serge,

I will chang that today, but for now I first have to do my homework... Crying or Very sad

Edit1: I changed the first few problems, but I could find the one with the 'list' command... Maybe you can give me an example?
Back to top
View user's profile Send private message
Serge
Professional Member
Professional Member


Joined: 04 Mar 2002
Posts: 1480
Location: Australia

PostPosted: Sun Mar 09, 2003 2:29 pm    Post subject: Reply with quote

hi skit3000,

found the problem! it appears that vds does not totally like using I instead of IF (especially if you have IF END inside another IF END)

i changed your code so that it would leave IF alone and it works just great!!!

i have also made some changes to the interface (added a level to keep user informed of progress, made 2 text as "hyperlinks" to load default values in edit boxes, the program will now also remove all blank lines and all REM lines - i've been able to save 36% for one of my programs this way)

when you have a moment and if you would like, could you write a subroutine to convert all functions to shorthand notation as well eg. @EQUAL would become @E, @NOT would become @N and so on...

by shorthanding the functions, we could acheive 50% saving on the code, i expect

of course, your homework comes first Smile Smile Smile

Serge

_________________
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Sun Mar 09, 2003 3:16 pm    Post subject: Reply with quote

Hi Serge,

I thought about shorthanding functions, but that will take a long time, because you have to test every command... About your subroutine which removes REM lines: they will automatic be removed when you compile a script with VDS. The same for blank lines. Variables are automatic shorten to a one character variable, like & %■...

But I'll look at the functions when I have time...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> Visual DialogScript Open Source Projects All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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