Board index » delphi » Break Point

Break Point

Did ask this (differently under the tile of 'Brek Point') in ObjectPascal
NG, got some feed back, trying to seek some more
professional opinions here.

Simple code no threads or anything complicated no recursive operation,
openning 2 MSWord docs in the background and swapping in between to cut and
paste texts and some graphics insersion.  With a break point it places
everything right in designated places including graphics
but without a break point it misplaces the correct place especially for
graphics.

The weird thing is that a delay of say Sleep(1000) - (10000) makes no
different,
although a break point or a ShowMessage('') does.

regards

 

Re:Break Point


<<Az:
With a break point it places everything right in designated
places including graphics but without a break point it
misplaces the correct place especially for graphics.

Quote

Can you show us the code?

--
Deborah Pate (TeamB) http://delphi-jedi.org

  TeamB don't see posts sent via Google or ISPs
  Use the real Borland server: newsgroups.borland.com
  http://www.borland.com/newsgroups/genl_faqs.html

Re:Break Point


Hi,
Do you want me to submit the code here or to your email address.

regards

"Deborah Pate (TeamB)" <d.p...@blueyonder.co.not-this-bit.uk> wrote in
message news:VA.00001c75.00148754@blueyonder.co.not-this-bit.uk...

Quote
> <<Az:
> With a break point it places everything right in designated
> places including graphics but without a break point it
> misplaces the correct place especially for graphics.

> Can you show us the code?

> --
> Deborah Pate (TeamB) http://delphi-jedi.org

>   TeamB don't see posts sent via Google or ISPs
>   Use the real Borland server: newsgroups.borland.com
>   http://www.borland.com/newsgroups/genl_faqs.html

Re:Break Point


<<Az:
Do you want me to submit the code here

Quote

Here please - and only the relevant bits, not the whole
project, thanks. :)

--
Deborah Pate (TeamB) http://delphi-jedi.org

  TeamB don't see posts sent via Google or ISPs
  Use the real Borland server: newsgroups.borland.com
  http://www.borland.com/newsgroups/genl_faqs.html

Re:Break Point


Here is an excerpt of the actual method.  Look for ShowMessage('Press enter
to continue.') in code if this is or Break Point not exists then the
following image does not get inserted in the selected range.

Code:

            try
              for lIndex := 1 to 6 do
              begin
                lMainDoc.Activate;

                Selection.Find.ClearFormatting;
                loleUnit := wdStory;
                loleExtend := EmptyParam;
                Selection.HomeKey(loleUnit, loleExtend);
                lSearchValueFound := True;
                while lSearchValueFound do
                begin
                  loleSearchValue :=
MapIndexToDefinedConstantsDescription(lIndex);
                  loleSearchForward := True;
                  if Selection.Find.Execute(loleSearchValue,
                               EmptyParam,
                               EmptyParam,
                               EmptyParam,
                               EmptyParam,
                               EmptyParam,
                               loleSearchForward,
                               EmptyParam,
                               EmptyParam,
                               EmptyParam,
                               EmptyParam) then
                  begin
                    {get selection formatted information}
                    loleFontName := Selection.Range.FormattedText.Font.Name;
                    loleFontSize := Selection.Range.FormattedText.Font.Size;
                    loleColourIndex :=
Selection.Range.FormattedText.Font.ColorIndex;
                    loleBold     := Selection.Range.FormattedText.Bold;
                    loleUnderLine:= Selection.Range.FormattedText.Underline;

                    lSearchValueFound := True;
                    {delete tag}
                    loleCount := 1;
                    loleUnit  := wdCharacter;
                    Selection.Delete(loleUnit, loleCount);

                    loleTextColumnCount :=
Selection.PageSetup.TextColumns.Count;
                    if loleTextColumnCount = 1 then lMoreThanOneTextColumn
:= False;
                    if loleTextColumnCount > 1 then
                    begin
                      lMoreThanOneTextColumn := True;
                      loleTextColumnSpacing :=
Selection.PageSetup.TextColumns.Spacing;
                    end;

                    lTemp := rLogin.LocalDrive +
cMailMergeTemplateWorkingFolder + loleSearchValue;

                    {insert the description into temp doc}
                    lTempDoc.Activate;
                    Selection.InsertFile(lTemp,
                             EmptyParam,
                             EmptyParam,
                             EmptyParam,
                             EmptyParam);
                    {back to beginng of doc}
                    loleUnit := wdStory;
                    loleExtend := EmptyParam;
                    Selection.HomeKey(loleUnit, loleExtend);
                    lContinue := True;

                    repeat

                      lTempDoc.Activate;
                      lParams := TParameterList.Create;
                      try
                        AnalyseDescription(lTemp + '.txt', lParams);
                        {set variables based on aParameterList values}
                        lPageBreak  :=
Boolean(StrToIntDef(lParams.GetParamValue(cPageBreak), 0));
                        lTextToRight:=
Boolean(StrToIntDef(lParams.GetParamValue(cTextToRight), 0));
                        lXFOCode          :=
lParams.GetParamValue(cXFOCode);
                        lPhotoTablePhotos :=
lParams.GetParamValue(cPhotoTablePhotos);
                        lContinue         :=
Boolean(StrToIntDef(lParams.GetParamValue(cAnyTexToMerge), 0));
                        lTextBeforeTag    :=
Boolean(StrToIntDef(lParams.GetParamValue(cTextBeforeTag), 0));
                        lTextAfterTag     :=
Boolean(StrToIntDef(lParams.GetParamValue(cTextAfterTag), 0));
                        lTagAfterTag      :=
Boolean(StrToIntDef(lParams.GetParamValue(cSpecialTagAfterTag), 0));
                        lSpecialTagFound  :=
Boolean(StrToIntDef(lParams.GetParamValue(cSpecialTag), 0));
                        lPairedXFOCode    :=
Boolean(StrToIntDef(lParams.GetParamValue(cPaired), 0));
                        lPairedXFOCodeFound
                                          :=
Boolean(StrToIntDef(lParams.GetParamValue(cPairedXFOCodeFound), 0));
                        lPairCodeOnSameLine
                                          :=
Boolean(StrToIntDef(lParams.GetParamValue(cPairCodeOnSameLine), 0));

                      finally
                        FreeAndNil(lParams);
                      end;
                      if not lContinue then
                      begin
                        lMainDoc.Activate;
                        Break;
                      end;

                      {now find the XFOCode (this code includes not only xfo
but all special codes) in the temp doc}
                      if lSpecialTagFound then
                      begin
                        {back to beginng of temp doc}
                        loleUnit := wdStory;
                        loleExtend := EmptyParam;
                        Selection.HomeKey(loleUnit, loleExtend);
                        Selection.Find.ClearFormatting;
                        loleSearchForward := True;
                        loleSearchValue   := lXFOCode;
                        if Selection.Find.Execute(loleSearchValue,
                                     EmptyParam,
                                     EmptyParam,
                                     EmptyParam,
                                     EmptyParam,
                                     EmptyParam,
                                     loleSearchForward,
                                     EmptyParam,
                                     EmptyParam,
                                     EmptyParam,
                                     EmptyParam) then
                        begin
                          {Delete the tag in Temp doc
                          this delete, deletes any paired codes if its
occurance is on the same line}
                          loleUnit := wdLine;
                          Selection.EndKey(loleUnit, EmptyParam);
                          loleUnit := wdLine;
                          loleExtend := wdExtend;
                          Selection.HomeKey(loleUnit, loleExtend);
                          loleCount := 1;
                          Selection.MoveUp(loleUnit, loleCount, loleExtend);
                          Selection.EndKey(loleUnit, loleExtend);
                          loleUnit := wdCharacter;
                          Selection.Delete(loleUnit, loleCount);
                          {check also if XFOCode is paired then delete the
paired code as well (only if not on same line}
                          case lPairedXFOCodeFound of
                            True  :   begin
                                        case lPairCodeOnSameLine of
                                          False :   begin
                                                      if not lTextToRight
then
                                                      begin

Selection.Find.ClearFormatting;
                                                        loleSearchForward :=
True;
                                                        loleSearchValue :=
cWaitPhotoCode;
                                                         if
Selection.Find.Execute(loleSearchValue,

EmptyParam,

EmptyParam,

EmptyParam,

EmptyParam,

EmptyParam,

loleSearchForward,

EmptyParam,

EmptyParam,

EmptyParam,

EmptyParam) then
                                                        begin
                                                          {Delete the tag in
Temp doc}
                                                          loleUnit :=
wdLine;

Selection.EndKey(loleUnit, EmptyParam);
                                                          loleUnit :=
wdLine;
                                                          loleExtend :=
wdExtend;

Selection.HomeKey(loleUnit, loleExtend);
                                                          loleCount := 1;

Selection.MoveUp(loleUnit, loleCount, loleExtend);

Selection.EndKey(loleUnit, loleExtend);
                                                          loleUnit :=
wdCharacter;

Selection.Delete(loleUnit, loleCount);
                                                        end;
                                                      end;
                                                    end;
                                        end;
                                      end;
                          end;

                          {as there will be section already in the template,
therefore, no need
                          to insert a new section at this stage.  Check if
text exists before XFOCode then paste
                          it here}
                          if lTextBeforeTag then
                          begin
                            loleUnit := wdLine;
                            Selection.MoveDown(loleUnit, loleCount,
EmptyParam);
                            Selection.HomeKey(loleUnit, EmptyParam);
                            loleUnit := wdStory;
                            loleExtend := wdExtend;
                            Selection.HomeKey(loleUnit, loleExtend);

                            {apply the format obtained from the merge field
from the main doc if applicable}
                            if loleFontName <> '' then
Selection.Range.Font.Name := loleFontName;
                            Selection.Font.Size := loleFontSize;
                            if loleUnderLine <> 0 then
Selection.Range.Underline := loleUnderLine;
                            if loleBold <> 0 then Selection.Range.Bold :=
loleBold;
                            if loleColourIndex <> 0 then
...

read more »

Re:Break Point


Quote
> The weird thing is that a delay of say Sleep(1000) - (10000) makes no
> different,
> although a break point or a ShowMessage('') does.

Have you tried an Application.ProcessMessages?

Oliver Townshend

Re:Break Point


Yep, I did but with no luck.

regards

Quote
"Oliver Townshend" <oli...@zip.com.au> wrote in message

news:3eb11e4a@newsgroups.borland.com...
Quote
> > The weird thing is that a delay of say Sleep(1000) - (10000) makes no
> > different,
> > although a break point or a ShowMessage('') does.

> Have you tried an Application.ProcessMessages?

> Oliver Townshend

Other Threads