Hello Everyone
Today we are going to discuss Super Controls in Alpha Software. Super controls in Alpha Software are cool and bring a professional and modern look to your application. However, they don’t necessarily meet the needs of all developers; also, for developers using older versions of Alpha5 these super controls simply are not available. There is another solution. Design your own Super Control using xBasic and existing objects in Alpha5.
To demonstrate how this works, we are going to make a simple embedded calendar using a multistate button and xBasic code. This procedure will work for versions 5 and up.
For this example, the finished calendar is shown here.
Now, you can use any form tools to jazz up the calendar and add navigation buttons and or drop down list to make it work the way you want.
To start, we created our form then added three variables to the form.
vDate Date Variable
vDay Numeric Variable
tDate Character Variable
Next we set the OnInit event to assign the current date to vDate and tDate. Since tDate is a character string we need to convert it with:
DTOC(Date())
then we run a script called refreshcal
The code for refreshcal is listed here:
'Assign vDate and frame label CustomSuperControl:vdate.refresh() CustomSuperControl:frame1.text = " "+cmonth(vDate)+" " 'Set value for lvar dim SHARED lvar as N lvar = dow(month_start(vDate))-1 'Build first row of buttons CustomSuperControl:mulstbtn1.choice.list[1].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[1].value)-Var->lvar)) if val(CustomSuperControl:mulstbtn1.choice.list[1].text) < 1 then CustomSuperControl:mulstbtn1.choice.list[1].text = Alltrim(str(day(Date_LastDayOfPreviousMonth(vDate))+Val(CustomSuperControl:mulstbtn1.choice.list[1].value)-Var->lvar)) end if CustomSuperControl:mulstbtn1.choice.list[2].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[2].value)-Var->lvar)) if val(CustomSuperControl:mulstbtn1.choice.list[2].text) < 1 then CustomSuperControl:mulstbtn1.choice.list[2].text = Alltrim(str(day(Date_LastDayOfPreviousMonth(vDate))+Val(CustomSuperControl:mulstbtn1.choice.list[2].value)-Var->lvar)) end if CustomSuperControl:mulstbtn1.choice.list[3].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[3].value)-Var->lvar)) if val(CustomSuperControl:mulstbtn1.choice.list[3].text) < 1 then CustomSuperControl:mulstbtn1.choice.list[3].text = Alltrim(str(day(Date_LastDayOfPreviousMonth(vDate))+Val(CustomSuperControl:mulstbtn1.choice.list[3].value)-Var->lvar)) end if CustomSuperControl:mulstbtn1.choice.list[4].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[4].value)-Var->lvar)) if val(CustomSuperControl:mulstbtn1.choice.list[4].text) < 1 then CustomSuperControl:mulstbtn1.choice.list[4].text = Alltrim(str(day(Date_LastDayOfPreviousMonth(vDate))+Val(CustomSuperControl:mulstbtn1.choice.list[4].value)-Var->lvar)) end if CustomSuperControl:mulstbtn1.choice.list[5].text = Alltrim(str(val(CustomSuperControl:mulstbtn1.choice.list[5].value)-Var->lvar)) if val(CustomSuperControl:mulstbtn1.choice.list[5].text) < 1 then CustomSuperControl:mulstbtn1.choice.list[5].text = Alltrim(str(day(Date_LastDayOfPreviousMonth(vDate))+Val(CustomSuperControl:mulstbtn1.choice.list[5].value)-Var->lvar)) end if CustomSuperControl:mulstbtn1.choice.list[6].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[6].value)-Var->lvar)) if val(CustomSuperControl:mulstbtn1.choice.list[6].text) < 1 then CustomSuperControl:mulstbtn1.choice.list[6].text = Alltrim(str(day(Date_LastDayOfPreviousMonth(vDate))+Val(CustomSuperControl:mulstbtn1.choice.list[6].value)-Var->lvar)) end if CustomSuperControl:mulstbtn1.choice.list[7].text = Alltrim(str(val(CustomSuperControl:mulstbtn1.choice.list[7].value)-Var->lvar)) if val(CustomSuperControl:mulstbtn1.choice.list[7].text) < 1 then CustomSuperControl:mulstbtn1.choice.list[7].text = Alltrim(str(day(Date_LastDayOfPreviousMonth(vDate))+Val(CustomSuperControl:mulstbtn1.choice.list[7].value)-Var->lvar)) end if 'build middle rows CustomSuperControl:mulstbtn1.choice.list[8].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[8].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[9].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[9].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[10].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[10].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[11].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[11].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[12].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[12].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[13].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[13].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[14].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[14].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[15].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[15].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[16].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[16].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[17].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[17].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[18].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[18].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[19].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[19].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[20].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[20].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[21].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[21].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[22].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[22].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[23].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[23].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[24].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[24].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[25].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[25].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[26].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[26].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[27].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[27].value)-Var->lvar)) CustomSuperControl:mulstbtn1.choice.list[28].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[28].value)-Var->lvar)) 'Build last row of buttons dim xldom as N xldom = day(Month_End(vDate)) CustomSuperControl:mulstbtn1.choice.list[29].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[29].value)-Var->lvar)) if val(CustomSuperControl:mulstbtn1.choice.list[29].text) > Var->xldom then CustomSuperControl:mulstbtn1.choice.list[29].text = Alltrim(str(val(CustomSuperControl:mulstbtn1.choice.list[29].text)-Var->xldom)) end if CustomSuperControl:mulstbtn1.choice.list[30].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[30].value)-Var->lvar)) if val(CustomSuperControl:mulstbtn1.choice.list[30].text) > Var->xldom then CustomSuperControl:mulstbtn1.choice.list[30].text = Alltrim(str(val(CustomSuperControl:mulstbtn1.choice.list[30].text)-Var->xldom)) end if CustomSuperControl:mulstbtn1.choice.list[31].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[31].value)-Var->lvar)) if val(CustomSuperControl:mulstbtn1.choice.list[31].text) > Var->xldom then CustomSuperControl:mulstbtn1.choice.list[31].text = Alltrim(str(val(CustomSuperControl:mulstbtn1.choice.list[31].text)-Var->xldom)) end if CustomSuperControl:mulstbtn1.choice.list[32].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[32].value)-Var->lvar)) if val(CustomSuperControl:mulstbtn1.choice.list[32].text) > Var->xldom then CustomSuperControl:mulstbtn1.choice.list[32].text = Alltrim(str(val(CustomSuperControl:mulstbtn1.choice.list[32].text)-Var->xldom)) end if CustomSuperControl:mulstbtn1.choice.list[33].text = Alltrim(str(val(CustomSuperControl:mulstbtn1.choice.list[33].value)-Var->lvar)) if val(CustomSuperControl:mulstbtn1.choice.list[33].text) > Var->xldom then CustomSuperControl:mulstbtn1.choice.list[33].text = Alltrim(str(val(CustomSuperControl:mulstbtn1.choice.list[33].text)-Var->xldom)) end if CustomSuperControl:mulstbtn1.choice.list[34].text = Alltrim(str(Val(CustomSuperControl:mulstbtn1.choice.list[34].value)-Var->lvar)) if val(CustomSuperControl:mulstbtn1.choice.list[34].text) > Var->xldom then CustomSuperControl:mulstbtn1.choice.list[34].text = Alltrim(str(val(CustomSuperControl:mulstbtn1.choice.list[34].text)-Var->xldom)) end if CustomSuperControl:mulstbtn1.choice.list[35].text = Alltrim(str(val(CustomSuperControl:mulstbtn1.choice.list[35].value)-Var->lvar)) if val(CustomSuperControl:mulstbtn1.choice.list[35].text) > Var->xldom then CustomSuperControl:mulstbtn1.choice.list[35].text = Alltrim(str(val(CustomSuperControl:mulstbtn1.choice.list[35].text)-Var->xldom)) end if 'Set button choice to match vDate and refresh form CustomSuperControl:mulstbtn1.text = Alltrim(str(day(vdate)+lvar)) parentform.commit()
add the refreshcal to the on change event of vDate on the form to rebuild the button labels when the date is changed. Use the on push event for the Today’s Date field to set vDate to the current date and again run refreshcal.
That’s all there is to it. Watch the short video to see how it’s done
Well I hope you found this tip useful and if you are trying to do something similar or need help with an Alpha Software project we are here to help. All work is guaranteed and you only pay for what you approve.

Leave a comment