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 


@winexists

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


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Wed Mar 22, 2006 1:49 pm    Post subject: @winexists Reply with quote

I have a program that removes one dialog element (a table) and replaces it with another when a certain button is pressed. I would like for that button code to be able to know when TableA is present or when TableB is present, so it can swap them out when the button is pressed again.

I thought that @winexists(~TableA) would let me know if it existed, but instead of it returning a null value, I get a runtime error. Here is code I used to test it:

Code:
DIALOG CREATE,New Dialog,-1,0,240,160
  DIALOG ADD,TABLE,TableA,9,25,184,74,Column 1[80]|Column 2[80]|Column 3[80]
  DIALOG SHOW

  if @winexists(~tableB)
     info It exists.
  else
     info It does not exist.
  end


The error I get is: Unhandled Exception ""

I am using Win XP Pro, SP2. Anyone have any ideas? Am I doing something wrong?

_________________
Joe Floyd
Back to top
View user's profile Send private message
WidgetCoder
Contributor
Contributor


Joined: 28 May 2002
Posts: 126
Location: CO, USA

PostPosted: Wed Mar 22, 2006 3:48 pm    Post subject: Reply with quote

Apparently the "~" is an explicit reference and VDS assumes the element to be present.

Try:

Code:
 
  DIALOG CREATE,New Dialog,-1,0,240,160
  dialog add,line,Ln1,9,25,184,74
  DIALOG ADD,TABLE,TableA,9,25,184,74,Column 1[80]|Column 2[80]|Column 3[80]
  DIALOG ADD,BUTTON,BUTTON1,106,27,183,24,Remove Table
  DIALOG SHOW
  %%TableVis = 1
 
:Evloop
  wait event
  goto @event()

:Button1BUTTON
  if @zero(%%TableVis)
    dialog add,line,Ln1,9,25,184,74
    DIALOG ADD,TABLE,TableA,9,25,184,74,Column 1[80]|Column 2[80]|Column 3[80]
    dialog set,Button1,Remove Table
    %%TableVis = 1
  else
    dialog remove,Ln1
    dialog set,Button1,Add Table
    %%TableVis = 0
  end
  goto evloop
Back to top
View user's profile Send private message Send e-mail
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Wed Mar 22, 2006 5:05 pm    Post subject: Reply with quote

That must be it. Thanks for the suggestion. I had thought of that, and may do something like that - but unfortunately, I am near the limit for the number of variables in my script! I reuse them when I can, but I don't have many to spare.

Thanks for the reply.

_________________
Joe Floyd
Back to top
View user's profile Send private message
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Wed Mar 22, 2006 5:08 pm    Post subject: Reply with quote

Nevermind.. if there is a dialog showing, it gives an unhandled exception.. pretty odd.
_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
WidgetCoder
Contributor
Contributor


Joined: 28 May 2002
Posts: 126
Location: CO, USA

PostPosted: Wed Mar 22, 2006 5:47 pm    Post subject: Reply with quote

jwfv wrote:
unfortunately, I am near the limit for the number of variables in my script!

You could use @winexists and errortrap to test the existence but that seems like a long fix to a short problem. Good luck!
Back to top
View user's profile Send private message Send e-mail
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Wed Mar 22, 2006 6:27 pm    Post subject: Reply with quote

I guess I could add a text dialog element with zero width and height, and set the text in it to identify which table was showing. Then using @dlgtext(), I can read the value.
_________________
Joe Floyd
Back to top
View user's profile Send private message
WidgetCoder
Contributor
Contributor


Joined: 28 May 2002
Posts: 126
Location: CO, USA

PostPosted: Wed Mar 22, 2006 7:37 pm    Post subject: Reply with quote

Try:
Code:

  DIALOG CREATE,New Dialog,-1,0,240,160
  DIALOG ADD,line,Ln1,9,25,184,74
  DIALOG ADD,TABLE,TableA,9,25,184,74,Column 1[80]|Column 2[80]|Column 3[80]
  DIALOG ADD,BUTTON,BUTTON1,106,27,183,24,Remove Table
  DIALOG SHOW 

:Evloop
  wait event
  goto @event()

:Button1BUTTON
  # Looks stupid but it works without using a Var
  if @equal(@dlgpos(TableA,L),25)
    dialog remove,Ln1
    dialog set,Button1,Add Table
  else
   dialog add,line,Ln1,9,25,184,74
   DIALOG ADD,TABLE,TableA,9,25,184,74,Column 1[80]|Column 2[80]|Column 3[80]
   dialog set,Button1,Remove Table
  end
  goto evloop
:close
  exit
Back to top
View user's profile Send private message Send e-mail
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Wed Mar 22, 2006 8:07 pm    Post subject: Reply with quote

Interesting - thanks for the tip. When I tested your code a little further, I found that it just returns a really large number as the result of the @dlgpos() function (if that element doesn't exist). I wonder why that is? If it returned zero or something reliable, then we wouldn't have to compare it to the original position.

What I have done for now is use a 0x0 text element to hold the "toggle" value.

I also found that if I removed, then added, elements several times, I got a memory error. So instead I created both tables and then hid one of them. Then when they toggle, I just hide one and show the other. No errors.

Thanks for the feedback.

_________________
Joe Floyd
Back to top
View user's profile Send private message
WidgetCoder
Contributor
Contributor


Joined: 28 May 2002
Posts: 126
Location: CO, USA

PostPosted: Wed Mar 22, 2006 8:18 pm    Post subject: Reply with quote

jwfv wrote:
I also found that if I removed, then added, elements several times, I got a memory error


I'm curious when you received the "memory error" were you removing the table itself or the table in a container e.g.: line or group element?

I believe there's something in VDS's help file under known issues relating to using tables on tabs but I have found the problem to be more generalized. Using a line element as in the example above has always worked for me.
Back to top
View user's profile Send private message Send e-mail
jwfv
Valued Contributor
Valued Contributor


Joined: 19 Mar 2002
Posts: 422
Location: Beaufort, SC

PostPosted: Wed Mar 22, 2006 8:33 pm    Post subject: Reply with quote

You are right - I remember something about that. And I got the error from removing a table on a group element.
_________________
Joe Floyd
Back to top
View user's profile Send private message
WidgetCoder
Contributor
Contributor


Joined: 28 May 2002
Posts: 126
Location: CO, USA

PostPosted: Wed Mar 22, 2006 9:21 pm    Post subject: Reply with quote

I think the table issue most likely was just first noticed while using a tab control since you're constantly having to add and remove elements with a tab. The issue seems to have nothing in common with the use of a tab control itself but rather the act of removing a table directly. Apparently the table element isn't cleaning up after itself leaving pointers hanging to nonexistent memory.

I hope this issue gets resolved in v6! having to use a container to do the cleanup isn't the best workaround.

BTW: Your right about the @dlgpos issue, if the element doesn't exist it should change the @ok to null but doesn't. I tried using an "if @ok" statement first but it was always non-null since the function was returning errant number. I'd post this bug in the proper section if I thought for a second that someone at CR would actually read it.
Back to top
View user's profile Send private message Send e-mail
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