home *** CD-ROM | disk | FTP | other *** search
- REM Description: Add bullets to selected paragraphs.
- REM Filename: bullets.wmc
- REM Created by: Steve Wylie - 11/08/93
-
- REM Can't run if no document open
- IF GetDocName$() = "" THEN
- MESSAGE "Please create a new document or open an existing document first."
- STOP
- ENDIF
-
- REM Can't run in frame mode
- ret% = ViewEditMode(1)
- IF ret% = 2 THEN
- ret% = ViewEditMode(2)
- BEEP
- STOP
- ENDIF
-
- REM The following two arrays describe 27 different bullets.
- CONST MAXBULLETS% = 27
- CONST BulletFont$ = "Wingdings" ' Change the font if you have a different bullet font. Only one font can be used.
- DIM bullets%(MAXBULLETS%)
- DIM bulletStr$(MAXBULLETS%+1)
- bullets%(1) = ASC("Q") ' airplane
- bullets%(2) = 220 ' arrow - inside circle
- bullets%(3) = 240 ' arrow - open
- bullets%(4) = 216 ' arrow - stylish
- bullets%(5) = 165 ' bullseye
- bullets%(6) = 252 ' checkmark
- bullets%(7) = ASC("m") ' circle with shadow
- bullets%(8) = ASC("V") ' cross
- bullets%(9) = ASC("u") ' diamond
- bullets%(10) = ASC("F") ' finger pointing right
- bullets%(11) = ASC("O") ' flag
- bullets%(12) = ASC("=") ' floppy disk
- bullets%(13) = ASC("{") ' flower
- bullets%(14) = ASC("v") ' four diamonds
- bullets%(15) = 207 ' leaf
- bullets%(16) = ASC("8") ' mouse
- bullets%(17) = 33 ' pencil
- bullets%(18) = ASC("J") ' smile
- bullets%(19) = ASC("T") ' snowflake
- bullets%(20) = ASC("q") ' square with shadow
- bullets%(21) = 171 ' star
- bullets%(22) = ASC("Y") ' star of david
- bullets%(23) = 182 ' star with shadow
- bullets%(24) = ASC("(") ' telephone
- bullets%(25) = ASC("C") ' thumbs up
- bullets%(26) = 255 ' windows logo
- bullets%(27) = 251 ' x marks the spot
-
- REM These are the strings that appear in the dialog.
- bulletStr$(1) = "Airplane"
- bulletStr$(2) = "Arrow Inside Circle"
- bulletStr$(3) = "Arrow - Open"
- bulletStr$(4) = "Arrow - Stylized"
- bulletStr$(5) = "Bullseye"
- bulletStr$(6) = "Checkmark"
- bulletStr$(7) = "Circle with Shadow"
- bulletStr$(8) = "Cross"
- bulletStr$(9) = "Diamond"
- bulletStr$(10) = "Finger Pointing"
- bulletStr$(11) = "Flag"
- bulletStr$(12) = "Floppy Disk"
- bulletStr$(13) = "Flower"
- bulletStr$(14) = "Four Diamonds"
- bulletStr$(15) = "Leaf"
- bulletStr$(16) = "Mouse"
- bulletStr$(17) = "Pencil"
- bulletStr$(18) = "Smile"
- bulletStr$(19) = "Snowflake"
- bulletStr$(20) = "Square with Shadow"
- bulletStr$(21) = "Star"
- bulletStr$(22) = "Star of David"
- bulletStr$(23) = "Star with Shadow"
- bulletStr$(24) = "Telephone"
- bulletStr$(25) = "Thumbs Up"
- bulletStr$(26) = "Windows Logo"
- bulletStr$(27) = "X Marks the Spot"
- bulletStr$(28) = "-- Remove Bullets --"
-
- frameType% = GetFrameType()
- IF frameType% <> 0 THEN
- Message "Bullets can only be inserted into text frames."
- STOP
- ENDIF
-
- index% = 1
- BEGIN DIALOG Dialog1 154, 128, "Bullets"
-
- TEXT 4, 4, 100, 8, "&Bullet:"
-
- LISTBOX 4, 14, 100, 80, bulletStr$, index%
-
- OKBUTTON 110, 4, 40, 14
-
- CANCELBUTTON 110, 20, 40, 14
-
- TEXT 4, 100, 146, 24, "Note: this macro works best if you select the paragraphs you want to apply the bullets to."
-
- END DIALOG
-
-
- ret% = DIALOG(Dialog1)
-
- IF ret% = 2 THEN STOP
-
-
- REM Freeze the screen so that the activity isn't visible
- freeze% = ViewFreezeScreen(1)
-
- REM Changed local% to 0 if you want the change to apply globally to the paragraph style.
- local% = 1
-
- REM Save the beginning and end of the selection
- yes% = GetTextOffset(strt%, end%)
-
- IF GetEditor() = 0 THEN
- switch% = 1 ' Remember to switch back when we're done.
- ViewEditor 1
- ENDIF
-
- REM If the save position bookmark is in the document, we must delete it.
- savePosMark$ = "docsavpos"
- IF ExistBookmark(savPosMark$) THEN
- EditGoto 7, , savPosMark$,
- InsertBookmark savPosMark$, , , , 1
- ENDIF
-
- IF strt% = 0 THEN strt% = 4
-
- IF yes% = 1 THEN
- REM Count the number of paragraphs
- EditGotoOffset strt%,
- DO
- ret% = GetTextOffset(savestart%, saveend%)
- ParaDown 1,
- CharRight 1,,
- ret% = GetTextOffset(start2%, end2%)
- numParagraphs% = numParagraphs% + 1
- LOOP UNTIL end2% >= end% OR end2% = saveend%
- REM Go to the beginning of the selection
- EditGotoOffset strt%, 0
- ELSE
- numParagraphs% = 1
- ENDIF
-
- adjust% = TO_DP("0.50",0)
- addStart% = 0
- count% = 0
- status$ = "Please wait... "
-
- FOR i% = 1 TO numParagraphs%
- REM Get the style information
- GetStyleParagraph first%, left%, right%, above%, below%, align%, location%, span%, hyphen%, numHyph%, keep%, allowBreak%, widow%
-
- REM Make sure the left indent is ahead of the first indent
- IF left% = first% AND index% < MAXBULLETS%+1 THEN left% = left% + adjust%
-
- REM If you choose None, then let's put the indents back to 0.
- IF left% > first% AND index% = MAXBULLETS%+1 THEN left% = first%
-
- REM Redefine the style with the new left indent.
- DefineStyle , local%
- DefineStyleParagraph first%, left%, , , , , , , , , , ,
- DefineStyleTabSet 0, 0, left% ' Make sure a tab is set at the left indent position
- DefineStyleBullet 0, 0, 0 ' Make sure there are no paragraph style bullets
- EndDefineStyle 1
-
- REM See if there are bullets from this macro already on the paragraph.
- StartOfPara
- ' Make sure we're not before the very first style tag.
- ret% = GetTextOffset(start%, e%)
- IF start% = 0 THEN EditGotoOffset 4,
- IF GetNextChar$(0) <> "" THEN WordRight 1, 1
- REM If there's a carriage return in the selection, back up one character.
- IF GetPrevChar$(0) = "<Cr>" THEN CharLeft 1, 1, 1
- bullet$ = GetSelection$()
- IF INSTR(bullet$, BulletFont$) AND INSTR(bullet$, "<Ft") THEN
- REM Delete the old bullet
- EditDelete ,
- count% = count% - 1 ' Decrease count% for every time you delete a bullet
- ENDIF
- IF i% = 1 AND count% = 0 AND index% < MAXBULLETS%+1 THEN addStart% = 1
- IF i% = 1 AND count% < 0 AND index% = MAXBULLETS%+1 THEN addStart% = -1
-
- REM Remove the selection.
- dummy% = GetTextOffset(s%, e%)
- EditGotoOffset s%, 0
-
- IF index% < MAXBULLETS%+1 THEN
- TypeText chr$(bullets%(index%))
- CharLeft 1, 1,
- StyleApplyFont BulletFont$
- CharRight 1,,
- TypeText "<Tb>"
- count% = count% + 1
- ENDIF
-
- REM Go to the next paragraph.
- ParaDown 1,0
- CharRight 1,,
- percent% = i% * 100 / numParagraphs%
- StatusMsg status$ + STR$(percent%) + "% finished."
- NEXT i%
-
- REM Restore the selection
- IF switch% = 1 THEN ViewEditor 0
- strt% = strt% + (addStart% * 8)
- IF strt% < 4 THEN strt% = 4
- EndOfStory 0
- ret% = GetTextOffset(s%, maxend%)
- EditGotoOffset strt%, 0
- end% = end% + (count% * 8)
- IF end% > maxend% THEN end% = maxend%
- if yes%=1 then EditGotoOffset end%, 1
-
- REM Restore the screen
- freeze% = ViewFreezeScreen(0)
-
- StatusMsg ""
- ***** WARNING *****
- This is a WSWin macro file.
- Subsequent data is binary information and should not be modified.