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 


Help: REPEAT ... @UNTIL

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
MondoNuovo
Valued Newbie


Joined: 09 Jul 2001
Posts: 44
Location: Italy

PostPosted: Sat Mar 16, 2002 12:43 pm    Post subject: Help: REPEAT ... @UNTIL Reply with quote

I am creating a little program, but I have a problem with the command REPEAT... @UNTIL.

The command must create all the DIALOG specified in %% LAST.

I do not know this command good, you can help me?


Code:

rem You create a .INI file with this structure:
rem [Setting]
rem Last=1
rem
rem [Note 1]
rem Top=0
rem Left=20
rem Width=200
rem Height=140
rem Caption=Welcome
rem Text=Welcome to StickyNote
rem
rem You save the file with this name: INIFILE.INI

inifile open,@curdir()\inifile.ini
%%last = @iniread(Setting,Last)
Title StickyNote

  DIALOG CREATE,StickyNote,0,0,0,0
  DIALOG ADD,TASKICON,TASK,icon.ico,StickyNote
 
gosub Load_Note

:Evloop
  wait event
  goto @event()

:taskClick
if @equal(@click(B), RIGHT)
dialog popup,New Note|-|Exit
end
goto evloop

:close
:ExitMenu
exit

:text_noteclick
if @equal(@click(B), RIGHT)
dialog popup,New Note|Hide|Delete
end
goto evloop

:HideMenu
goto evloop

:DeleteMenu
goto evloop


:New NoteMenu
inifile open,@curdir()\inifile.ini
%%last = @iniread(Setting,Last)

  DIALOG CREATE,New Post-It,-1,0,276,136,NOMIN
  DIALOG ADD,EDIT,caption,14,2,180,19,Title
  DIALOG ADD,TEXT,TEXT1,0,3,,,Caption:
  DIALOG ADD,EDIT,edit_note,48,2,180,84,Text here
  DIALOG ADD,BUTTON,OK,11,191,80,25,&OK,default
  DIALOG ADD,BUTTON,Cancel,48,191,80,25,Cancel
  DIALOG SHOW
  goto evloop
 
:CancelBUTTON
dialog close
wait event
%e = @event()
  goto evloop

:OKBUTTON
%%caption = @dlgtext(caption)
%%text_note = @dlgtext(edit_note)
if @null(@dlgtext(edit_note))@null(@dlgtext(caption))
goto evloop
else
%%num_note = @sum(%%last,1)
%%top = @iniread(Note %%last,Top)
%%left = @iniread(Note %%last,Left)
%%top1 = @sum(%%top,20)
%%left1 = @sum(%%left,10)
inifile write,Setting,Last,%%num_note
inifile write,Note %%num_note,Top,%%top1
inifile write,Note %%num_note,Left,%%left1
inifile write,Note %%num_note,Width,200
inifile write,Note %%num_note,Height,140
inifile write,Note %%num_note,Caption,%%caption
inifile write,Note %%num_note,Text,%%text_note

dialog close
wait event
%e = @event()
gosub ADD

end
goto evloop

:ADD
  DIALOG CREATE,%%caption,%%top1,%%left1,200,140,smallcap,resizable,nosys
  DIALOG ADD,STYLE,STYLE2,Arial,10,,YELLOW,FOREGROUND
  DIALOG ADD,STYLE,STYLE1,Arial,8,,YELLOW,YELLOW
  DIALOG ADD,TEXT,background,0,0,200,140,,STYLE1
  DIALOG ADD,TEXT,text_note,5,5,190,130,%%text_note,STYLE2,click
  DIALOG SHOW
exit


:LOAD_NOTE
if @equal(%%last,1)
gosub first
else
inifile open,@curdir()\inifile.ini
%%caption = @iniread(Note %%last,Caption)
%%text_note = @iniread(Note %%last,Text)
%%top = @iniread(Note %%last,Top)
%%left = @iniread(Note %%last,Left)
%%width = @iniread(Note %%last,Width)
%%height = @iniread(Note %%last,Height)
repeat
%%n_note = @pred(%%last)
inifile open,@curdir()\inifile.ini
%%caption = @iniread(Note %%n_note,Caption)
%%text_note = @iniread(Note %%n_note,Text)
%%top = @iniread(Note %%n_note,Top)
%%left = @iniread(Note %%n_note,Left)
%%width = @iniread(Note %%n_note,Width)
%%height = @iniread(Note %%n_note,Height)
  dialog create,%%caption,%%top,%%left,%%width,%%height,smallcap,resizable,nosys
  DIALOG ADD,STYLE,STYLE2,Arial,10,,YELLOW,FOREGROUND
  DIALOG ADD,STYLE,STYLE1,Arial,8,,YELLOW,YELLOW
  DIALOG ADD,TEXT,background,0,0,200,140,,STYLE1
  DIALOG ADD,TEXT,text_note,5,5,190,130,%%text_note,STYLE2,click
  DIALOG SHOW

until @equal(%%n_note,1)
:resize
  PARSE "%H;%W",@dlgpos(,HW)
DIALOG SETPOS,background,0,0,@diff(%W,0),@diff(%H,%%dh)
DIALOG SETPOS,text_note,5,5,@diff(%W,5),@diff(%H,%%dh)
 goto evloop
end
exit

:FIRST
inifile open,@curdir()\inifile.ini
%%caption = @iniread(Note %%last,Caption)
%%text_note = @iniread(Note %%last,Text)
%%top = @iniread(Note %%last,Top)
%%left = @iniread(Note %%last,Left)
%%width = @iniread(Note %%last,Width)
%%height = @iniread(Note %%last,Height)
  dialog create,%%caption,%%top,%%left,%%width,%%height,smallcap,resizable,nosys
  DIALOG ADD,STYLE,STYLE2,Arial,10,,YELLOW,FOREGROUND
  DIALOG ADD,STYLE,STYLE1,Arial,8,,YELLOW,YELLOW
  DIALOG ADD,TEXT,background,0,0,200,140,,STYLE1
  DIALOG ADD,TEXT,text_note,5,5,190,130,%%text_note,STYLE2,click
  DIALOG SHOW
  :resize
  PARSE "%H;%W",@dlgpos(,HW)
DIALOG SETPOS,background,0,0,@diff(%W,0),@diff(%H,%%dh)
DIALOG SETPOS,text_note,5,5,@diff(%W,5),@diff(%H,%%dh)
exit


Thanks in advance
Daniele
Back to top
View user's profile Send private message Send e-mail
Mac
Professional Member
Professional Member


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

PostPosted: Sat Mar 16, 2002 11:25 pm    Post subject: Reply with quote

I'd add a STATUS bar to the program for testing,
then display the value you're checking (%%n_note?)
from the REPEAT/UNTIL loop while it's running. You
can add a WAIT if the values are changing too fast.

You can also add @event() like this, so you can
break out of the loop manually by pressing any
button, etc. that causes an event:

until @equal(%%n_note,1)@event()

You can remove the status bar once you get the bugs
out. 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: Sun Mar 17, 2002 8:28 am    Post subject: Reply with quote

Another good way of debugging is to use the facilities of the VDS editor
itself: you can double-click the variable names that you wanna monitor
and they will show up in a debug window. Then run the script through
the "Debug script" button, and you can watch the variables change in the
window. Like Mac so wisely points out, you may want to put in WAIT commands
to slow down everything a bit.

Another thing that you may want to consider: The @curdir() may change
along the way - it's not necessarily the home directory of your program!
For this use, it may be wiser to use @path(%0) which will hold the path
to your program's startup directory.

Greetz
Dr. 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
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help 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