ToolBookDeveloper.com Knowledge Base  

Go Back   ToolBookDeveloper.com Knowledge Base > ToolBookDeveloper Product Information/Technical Support > Progress Bar Widget

Reply
 
Thread Tools Display Modes
  #1  
Old 06-15-2005, 02:05 AM
Peter Jackson's Avatar
Peter Jackson Peter Jackson is offline
Administrator
Site Admin
 
Join Date: Jan 2005
Posts: 31
Default Updating the Progress Bar Widget to TBK 2004 SP3 (DECAF)

Progress Bar - v8.9 SP3 (2004) Decaf

G'day and thank you for purchasing the Progress Bar Widget. With the new release of ToolBook 8.9 SP3 (2004) Decaf we now have the ability to change an objects' width. Actually this was always possible but not easily. Native ToolBook uses PageUnits and typically there are 15 PageUnits to one pixel and DHTML uses pixels, So before the release of Decaf the Progress Bar needed to divide the PageUnit value by 15 to get the correct number of pixels for the exported ToolBooks. Because we can now change the width of an object using the Actions Editor this conversion is automatic which means that the Method Action in the Progress Bar needs to be adjusted.

To make the upgrade simple for you I have provided some Automation script (OpenScript) below. This script will find all of the Progress Bars in your book and update the appropriate Method Action. You may be thinking "Why go to so much trouble when there is only one Progress Bar in my books?", I know of 3 separate customers that have used the Progress Bar on lots of pages, the following scripts will update ALL Progress Bars:-)

1. First add a button to any page.
2. Name it FixProgressBarSP3
3. Caption - Fix Progress Bar SP3 - Decaf
4. Set other button properties as you wish - color, font, etc.
5. Copy the following OpenScript and then paste into the button:

Code:
to handle buttonClick
	local stack bgObjs, pgObjs
	local object bgObj, pgObj
	local logical ss
	local int pUpdates
	forward
	ss = sysSuspend; sysSuspend = false; clear sysError
	newAction = "!setVariable,variable,!var,id 2,scope local,type <V>|,value,!op,id 3,term1,!op,id 12,term1,!op,id 4,term1,!param,num 1,type <V>|,term2,!literal,value 15,type <R>|,type <R>|,type <N>|,term2,!literal,value 15,type <R>|,type <R>|"
	oldAction = "!setVariable,variable,!var,id 2,scope local,type <V>|,value,!op,id 12,term1,!op,id 4,term1,!param,num 1,type <V>|,term2,!literal,value 15,type <R>|,type <R>|,type <N>|"
	newAction = ReplaceString(newAction,"!",ansiToChar(1))
	newAction = ReplaceString(newAction,"|",ansiToChar(2))
	oldAction = ReplaceString(oldAction,"!",ansiToChar(1))
	oldAction = ReplaceString(oldAction,"|",ansiToChar(2))
	pUpdates = 0
	bgObjs = backgrounds of this book
	while bgObjs <> null
		pop bgObjs into bgObj
		increment pUpdates by fixProgressBar(bgObj, oldAction, newAction) of self
		pgObjs = pages of bgObj
		while pgObjs <> null
			pop pgObjs into pgObj
			increment pUpdates by fixProgressBar(pgObj, oldAction, newAction) of self
		end while
	end while
	Msg = pUpdates && "Progress Bar/s updated"
	request Msg
	sysSuspend = ss; clear sysError
end buttonClick

to get fixProgressBar parentObj, oldAction, newAction
	local array actionArray[]
	local object widObj
	local int widCnt, pUpdates
	pUpdates= 0
	widObjs = getObjectList(parentObj,"group","ASYM_WID_Name")
	widCnt = itemCount(widObjs)
	step widNum from 1 to widCnt
		widObj = item widNum of widObjs
		if ASYM_WID_Name of widObj = "ProgressBar" and\
		  ASYM_WID_Author of widObj = "Peter Jackson - Nirvana Bound Pty Ltd" then
			ASYM_EA_IncludeChildObjects of widObj = true
			widObj = group "ProgressGroup" of widObj
			if sysError <> "" then
				clear sysError
				continue step
			end if
			ASYM_EA_IncludeChildObjects of widObj = true
			event = "setProgressBarWidth"
			actionArray = ASYM_EA_ActionMethod(event) of widObj
			if sysError <> "" then
				clear sysError
				continue step
			end if
			if actionArray[1] = oldAction then
				actionArray[1] = newAction
				ASYM_EA_ActionMethod(event) of widObj = actionArray
				increment pUpdates
			end if
		end if
	end step
	return pUpdates
end fixProgressBar
6. Go to reader and click the button.
7. Go to author, open the Catalog
8. Select the button and add it to the My objects category in the Catalog.
9. Delete the button from your book.

By adding the button to the Catalog as in step 8 above you now have the button in a place that you can simply add it to any book - simple:-)

To update the Progress Bar Widget in the Catalog, launch ToolBook and open the ProgressBar89.wbk file, which is in the ...\Instructor 2004\Catalog\ folder, then use the above button to update the Progress Bar.

BTW if you do update to Decaf and update the Progress Bar as per the above and then find that you need to uninstall Decaf to go back to SP1 then all that you need to do is swap the names of newAction and oldAction and then re-run the fix:-)
__________________
Hope this Helps :-)

Have a great day!
Peter

Peter Jackson
pjackson@toolbook.com
www.ToolBookDeveloper.com
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 01:32 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.