Recent

Author Topic: this works in Delphi  (Read 2410 times)

wolfdreamer

  • New Member
  • *
  • Posts: 15
this works in Delphi
« on: June 06, 2015, 02:19:35 pm »
i am running lazarus 1.4 on win 32

this section of code worked smoothly on Delphi. and as so many of the old codes i worked with back then i figered this should....

  StatusBar.Panels[sbpCursor].Text:= Format ('%D/%D',
     [core.CaretPos.y+1, core.CaretPos.x=1];

all it dose is take the x/y postion on a richmemo and display in a panel on the status bar. but this kicks up a error about '%d/%d'

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: this works in Delphi
« Reply #1 on: June 06, 2015, 02:29:04 pm »
i am running lazarus 1.4 on win 32

this section of code worked smoothly on Delphi. and as so many of the old codes i worked with back then i figered this should....

  StatusBar.Panels[sbpCursor].Text:= Format ('%D/%D',
     [core.CaretPos.y+1, core.CaretPos.x=1];

all it dose is take the x/y postion on a richmemo and display in a panel on the status bar. but this kicks up a error about '%d/%d'
Post all relevant information what you describe is not possible start with the precise error message and a working copy paste of the code. Please keep in mind that a rewrite of the existing code will not do we tend to pollute the code with our understanding leaving out details in the process. For example the code you posted has a typing error on the second parameter passed ee core.caretPos.x=1 is probably mend to be core.caretPos.x+1.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

lazjump

  • Jr. Member
  • **
  • Posts: 61
Re: this works in Delphi
« Reply #2 on: June 06, 2015, 05:45:24 pm »
Quote
  StatusBar.Panels[sbpCursor].Text:= Format ('%D/%D',
     [core.CaretPos.y+1, core.CaretPos.x=1];

Are you sure it worked in Delphi? Because core.CaretPos.x=1 would evaluate as boolean, not integer as you would like (give attention to the equal sign).

Perhaps it would work if you replace core.CaretPos.x=1 with something else like core.CaretPos.x
I thought Delphi was expensive until I learned the price of ExtJS

wolfdreamer

  • New Member
  • *
  • Posts: 15
(solved)Re: this works in Delphi
« Reply #3 on: June 06, 2015, 11:44:19 pm »
thank you.

I had looking at that code trying to work out what i'd messed up, and never noticed the typo.

correct typo code works.

 

TinyPortal © 2005-2018