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 


Can you change the text on TABS?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
ripburn
Newbie


Joined: 23 Dec 2004
Posts: 22

PostPosted: Fri Jan 07, 2005 10:02 am    Post subject: Can you change the text on TABS? Reply with quote

I have a Tab control with 7 tabs, 1 for each day of the week. Is it possible to change the text on the tabs so that Tab1 has "Mon" on it if today is Monday, and then tabs 2 to 7 have Tue to Sun respectively, and then on Tuesday Tab1 has Tue on it and tabs 2 to 7 have Wed to Mon respectively, and so on...

Obviously whatever Tab is clicked needs to generate a consistant event name... eg, Tab3CLICK

If I can't change the text on the Tabs is it possible to put somethong on top of each tab, say a text control, and have the tab event occur when the text is clicked?

Any help appreciated.

Cheers.

_________________
RipBurn
Back to top
View user's profile Send private message
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Fri Jan 07, 2005 11:20 am    Post subject: Reply with quote

No. The name of the tab is the name of the event. But since you are going to have to write code to name the tabs in the order you want them, it shouldn't be too hard to work back from "MonCLICK" to determine which tab was clicked.
_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Fri Jan 07, 2005 11:59 pm    Post subject: Reply with quote

Hi Ripburn,

Here is one way of doing it. After you run the following code, go into the Windows Date and Time Properties dialog and change your computer's date to another day... The application will then "update" itself automatically, in real time, and reset the tabs accordingly... Cool

Cheers,

- Boo

Code:


 %%firstrun = 1
  gosub dayvalues
  TITLE Day Tabs by Boo
  DIALOG CREATE,Day Tabs by Boo,224,117,756,245
  DIALOG ADD,STYLE,STYLE1,Arial,18,B,,RED
  rem *** Modified by Dialog Designer on 01/07/2005 - 16:56 ***
  DIALOG ADD,TAB,TAB1,12,4,746,221,%%Tab1|%%Tab2|%%Tab3|%%Tab4|%%Tab5|%%Tab6|%%Tab7
  DIALOG ADD,TEXT,TEXT1,91,92,,,Today is @datetime(dddd@chr(44) mmmm dd@chr(44) yyyy),,STYLE1
  DIALOG SHOW
:EVLOOP
  gosub dayvalues
  %E = @event()
  if @not(@null(%E))
  if @not(@equal(@pos(/,%E),0))
  %%day = @substr(%E,1,3)
  %E =
  goto tabclick
    end
  end
  if @not(@null(%E))
    GOTO %E
  end
  goto evloop
:CLOSE
  EXIT
:dayvalues
  %%today = @datetime(dddd|mmmm|dd|yyyy)
  %%today2 = @datetime(mm|dd|yy)
  parse "%%info1;%%info2;%%info3",%%today2
  parse "%%today3",%%today
  %%tab1 = @datetime(dddd) @datetime(mm/dd/yy)
  %%tab2 = @datetime(dddd,@fadd(@datetime(),1)) @datetime(mm/dd/yy,@fadd(@datetime(,%%info1/%%info2/%%info3),1))
  %%tab3 = @datetime(dddd,@fadd(@datetime(),2)) @datetime(mm/dd/yy,@fadd(@datetime(,%%info1/%%info2/%%info3),2))
  %%tab4 = @datetime(dddd,@fadd(@datetime(),3)) @datetime(mm/dd/yy,@fadd(@datetime(,%%info1/%%info2/%%info3),3))
  %%tab5 = @datetime(dddd,@fadd(@datetime(),4)) @datetime(mm/dd/yy,@fadd(@datetime(,%%info1/%%info2/%%info3),4))
  %%tab6 = @datetime(dddd,@fadd(@datetime(),5)) @datetime(mm/dd/yy,@fadd(@datetime(,%%info1/%%info2/%%info3),5))
  %%tab7 = @datetime(dddd,@fadd(@datetime(),6)) @datetime(mm/dd/yy,@fadd(@datetime(,%%info1/%%info2/%%info3),6))
    if @equal(%%firstrun,1)
    %%todayold = %%today
    %%firstrun = 0
    exit
  end
   
    if @not(@equal(%%today,%%todayold))
    dialog remove,Tab1
    DIALOG ADD,TAB,TAB1,12,4,746,221,%%Tab1|%%Tab2|%%Tab3|%%Tab4|%%Tab5|%%Tab6|%%Tab7
    DIALOG ADD,TEXT,TEXT1,91,92,,,Today is @datetime(dddd@chr(44) mmmm dd@chr(44) yyyy),,STYLE1
  end
  %%todayold = %%today
  exit
:tabclick
if @not(@equal(@pos(%%day,%%tab1),0))
dialog set,text1,You clicked the @chr(34)%%tab1@chr(34) tab!
end
if @not(@equal(@pos(%%day,%%tab2),0))
dialog set,text1,You clicked the @chr(34)%%tab2@chr(34) tab!
end
if @not(@equal(@pos(%%day,%%tab3),0))
dialog set,text1,You clicked the @chr(34)%%tab3@chr(34) tab!
end
if @not(@equal(@pos(%%day,%%tab4),0))
dialog set,text1,You clicked the @chr(34)%%tab4@chr(34) tab!
end
if @not(@equal(@pos(%%day,%%tab5),0))
dialog set,text1,You clicked the @chr(34)%%tab5@chr(34) tab!
end
if @not(@equal(@pos(%%day,%%tab6),0))
dialog set,text1,You clicked the @chr(34)%%tab6@chr(34) tab!
end
if @not(@equal(@pos(%%day,%%tab7),0))
dialog set,text1,You clicked the @chr(34)%%tab7@chr(34) tab!
end
goto evloop



Last edited by Boo on Sat Jan 08, 2005 7:53 pm; edited 1 time in total
Back to top
View user's profile Send private message
ripburn
Newbie


Joined: 23 Dec 2004
Posts: 22

PostPosted: Sat Jan 08, 2005 12:52 am    Post subject: Reply with quote

Thanks for the replies.

Changing the date is not an option as it has the potential to screw too many other things which rely upon the correct date.

As I'm only just starting out on this program I've decided to go with buttons instead of tabs... it's much simpler.

Cheers.

_________________
RipBurn
Back to top
View user's profile Send private message
Skit3000
Admin Team


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

PostPosted: Sat Jan 08, 2005 9:51 am    Post subject: Reply with quote

How about this? It will always put the current day at the first position, and the next six days after it... Smile

Code:
%%DayTabs = @datetime(ddd)|@datetime(ddd,@fadd(@datetime(),1))|@datetime(ddd,@fadd(@datetime(),2))|@datetime(ddd,@fadd(@datetime(),3))|@datetime(ddd,@fadd(@datetime(),4))|@datetime(ddd,@fadd(@datetime(),5))|@datetime(ddd,@fadd(@datetime(),6))

  DIALOG CREATE,New Dialog,-1,0,438,314
REM *** Gewijzigd door de Dialoog Ontwerper op 08-01-2005 - 10:50 ***
  DIALOG ADD,TAB,TAB1,5,5,430,310,%%DayTabs
  DIALOG SHOW

:Evloop
wait event
goto @event()

:MonCLICK
:TueCLICK
:WedCLICK
:ThuCLICK
:FriCLICK
:SatCLICK
:SunCLICK
info You clicked a tab!!!
goto Evloop

:Close
exit

_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Sat Jan 08, 2005 7:21 pm    Post subject: Reply with quote

Hi Skit3000,

Yeppers, that is cool. However, your code does not allow for "automatic" updates should the user leave her/his computer on 24/7. Also, I like to include the actual dates next to the day (i.e. Sat 01/08/05). I modified your code to accomplish some of this.

The previous example I posted also shows the exact "dynamic" tab text when clicked... Also, your code only indicates that a tab element has been clicked. I modified your code to show what day (i.e. Monday, Tuesday, etc.) was clicked....

Probably a more "streamlined" way to accomplish all of this, but like my previous example, I just threw this together on the fly... Wink

Cheers,

- Boo

Code:

%%firstrun = 1
DIALOG CREATE,New Dialog,-1,0,438,314
  rem *** Gewijzigd door de Dialoog Ontwerper op 08-01-2005 - 10:50 ***
DIALOG SHOW
:Evloop
gosub dayvalues
  %E = @event()
  if @not(@null(%E))
  if @not(@equal(@pos(/,%E),0))
  goto tabclick
  end
  goto %E
  end
  goto evloop

:tabclick
if @not(@equal(@pos(Sun,%E),0))
%%day = Sunday
end
if @not(@equal(@pos(Mon,%E),0))
%%day = Monday
end
if @not(@equal(@pos(Tue,%E),0))
%%day = Tuesday
end
if @not(@equal(@pos(Wed,%E),0))
%%day = Wednesday
end
if @not(@equal(@pos(Thu,%E),0))
%%day = Thursday
end
if @not(@equal(@pos(Fri,%E),0))
%%day = Friday
end
if @not(@equal(@pos(Sat,%E),0))
%%day = Saturday
end
info You clicked on the @chr(34)%%day@chr(34) tab!
goto Evloop

:Close
  exit
 
:dayvalues
%%today2 = @datetime(mm|dd|yy)
if @equal(%%firstrun,1)
%%firstrun = 0
%%today3 = %%today2
goto dayvalues2
end
if @not(@equal(%%today2,%%today3))
dialog remove,tab1
goto dayvalues2
end
exit
:dayvalues2
%%today3 = %%today2
parse "%%info1;%%info2;%%info3",%%today2
%%DayTabs = @datetime(ddd) @datetime(mm/dd/yy)|@datetime(ddd,@fadd(@datetime(),1)) @datetime(mm/dd/yy,@fadd(@datetime(,%%info1/%%info2/%%info3),1))|@datetime(ddd,@fadd(@datetime(),2)) @datetime(mm/dd/yy,@fadd(@datetime(,%%info1/%%info2/%%info3),2))|@datetime(ddd,@fadd(@datetime(),3)) @datetime(mm/dd/yy,@fadd(@datetime(,%%info1/%%info2/%%info3),3))|@datetime(ddd,@fadd(@datetime(),4)) @datetime(mm/dd/yy,@fadd(@datetime(,%%info1/%%info2/%%info3),4))|@datetime(ddd,@fadd(@datetime(),5)) @datetime(mm/dd/yy,@fadd(@datetime(,%%info1/%%info2/%%info3),5))|@datetime(ddd,@fadd(@datetime(),6)) @datetime(mm/dd/yy,@fadd(@datetime(,%%info1/%%info2/%%info3),6))
DIALOG ADD,TAB,TAB1,5,5,430,310,%%DayTabs
exit
Back to top
View user's profile Send private message
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Sat Jan 08, 2005 7:54 pm    Post subject: Reply with quote

FYI: Although it could probably be shortened even further, I streamlined my original example above to be somewhat shorter in length.

Cheers,

- Boo
Back to top
View user's profile Send private message
trapper
Contributor
Contributor


Joined: 28 Jan 2005
Posts: 112
Location: Brisbane, Australia

PostPosted: Mon Mar 14, 2005 9:46 am    Post subject: Reply with quote

I'm sure these examples worked for me at one time... but now I get a non-numeric value error at the line with @fadd(). Question

Regards.

_________________
John Trappett
Back to top
View user's profile Send private message
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Mon Mar 14, 2005 3:52 pm    Post subject: Reply with quote

Hi Trapper,

Are you sure your syntax is correct? That is, did you change the code from the one that was posted? What version of VDS are you running?

Because you are typing from Austrailia, perhaps your date is set up differently on your computer than the format I'm using?

Cheers,

- Boo
Back to top
View user's profile Send private message
trapper
Contributor
Contributor


Joined: 28 Jan 2005
Posts: 112
Location: Brisbane, Australia

PostPosted: Mon Mar 14, 2005 8:25 pm    Post subject: Reply with quote

You were right on the 2nd account Boo. When I changed my Regional Settings from English (Australia) to English (United States) it worked. When I changed it back again it failed. It probably worked previously because I tried it on a day in the month < 13.

I've now added the line:
Code:
  OPTION DATEFORMAT, mm/dd/yyyy

to the beginning of the code and it works with my Australian regional settings.

Regards.

_________________
John Trappett
Back to top
View user's profile Send private message
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Mon Mar 14, 2005 8:28 pm    Post subject: Reply with quote

Cool! Glad you got it working... Cool
Back to top
View user's profile Send private message
trapper
Contributor
Contributor


Joined: 28 Jan 2005
Posts: 112
Location: Brisbane, Australia

PostPosted: Mon Mar 14, 2005 8:34 pm    Post subject: Reply with quote

If you get a chance to look at it again I need an example where the number of Tabs is flexible... ie. there might be 7 days or there might be 14 or 21 or some number in between. It all depends on how many data files there are to be loaded (1 file for each day).

Regards.

_________________
John Trappett
Back to top
View user's profile Send private message
trapper
Contributor
Contributor


Joined: 28 Jan 2005
Posts: 112
Location: Brisbane, Australia

PostPosted: Wed Mar 16, 2005 2:46 am    Post subject: Reply with quote

trapper wrote:
If you get a chance to look at it again I need an example where the number of Tabs is flexible... ie. there might be 7 days or there might be 14 or 21 or some number in between. It all depends on how many data files there are to be loaded (1 file for each day).

Regards.

Code:
#----------------------
# Flexible Day Tab Demo
#----------------------

  # Change the TabCount variable to what you want
  %%TabCount = 20

  %%today = @datetime()
  %%TabString = @datetime(ddd dd/mm,%%today)
  %i = 1
  repeat
    %%TabString = %%TabString|@datetime(ddd dd/mm,@fadd(%%today,%i))
    %i = @succ(%i)
  until @equal(%i,%%TabCount)
  DIALOG CREATE,Flexible Day Tabs Demo,-1,0,494,283
  DIALOG ADD,STYLE,STYLE1,,18,B,,BLUE
  DIALOG ADD,TAB,TAB1,14,13,468,258,%%TabString
  DIALOG ADD,TEXT,TEXT1,120,25,435,30,,,STYLE1
  DIALOG SHOW
 
:Evloop
  WAIT EVENT
  %E = @event()
  if @not(@null(%E))
    if @not(@equal(@pos(/,%E),0))
      goto tabclick
    end
    goto %E
  end
  goto evloop

:Close
  exit
   
:tabclick
  %T = @substr(%E,1,9)
  %P = @pos(%T,%%TabString)
  if @greater(%P,1)
    %P = @succ(@div(@pred(%P),10))
  end
  dialog set, text1, "You clicked on Tab # "%P", "%T
  goto Evloop

_________________
John Trappett
Back to top
View user's profile Send private message
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Wed Mar 16, 2005 3:36 am    Post subject: Reply with quote

Hi John,

No time at the moment, but I'll try to take a look soon.

Cheers,

- Boo
Back to top
View user's profile Send private message
trapper
Contributor
Contributor


Joined: 28 Jan 2005
Posts: 112
Location: Brisbane, Australia

PostPosted: Wed Mar 16, 2005 5:13 am    Post subject: Reply with quote

Boo wrote:
Hi John,

No time at the moment, but I'll try to take a look soon.

Cheers,

- Boo
Thanks Boo... the example I just posted is doing just what I require. Now I just have to incorporate it into my program.

Regards.

_________________
John Trappett
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
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