2

i am working on component for delphi 7 and delphi 2006, the component uses SynTaskDialog.pas from synopse, i have successfully used the SynTaskDialog.pas in delphi 7 component, but when i try to use it in delphi 2006 to create a component package. i get an error

enter image description here

i have found a solution for the same on synopse.info/forum


Quote:

I've found two workarounds: Either

  1. replace the pointer arrays with string arrays like
  TD_ICONS_IDENT: array[TTaskDialogIcon] of string =(
    '', SMsgDlgWarning, SMsgDlgConfirm, SMsgDlgError, SMsgDlgInformation,
    '', SMsgDlgInformation);

and remove some LoadResString calls or

2.replace the pointer arrays with functions like

  GetIconIdent(TTaskDialogIcon): Pointer

but even after that i cannot compile the package for the component. and these errors come

 [Pascal Error] E2201 Need imported data reference ($G) to access 'SMsgDlgOK' from unit 'SynTaskDialog'
 [Pascal Error] E2201 Need imported data reference ($G) to access 'SMsgDlgYes' from unit 'SynTaskDialog'
 [Pascal Error] E2201 Need imported data reference ($G) to access 'SMsgDlgNo' from unit 'SynTaskDialog'
 [Pascal Error] E2201 Need imported data reference ($G) to access 'SMsgDlgCancel' from unit 'SynTaskDialog'
 [Pascal Error] E2201 Need imported data reference ($G) to access 'SMsgDlgRetry' from unit 'SynTaskDialog'
 [Pascal Error] E2201 Need imported data reference ($G) to access 'SCloseButton' from unit 'SynTaskDialog'
menjaraz
  • 7,551
  • 4
  • 41
  • 81
PresleyDias
  • 3,657
  • 6
  • 36
  • 62
  • You can find [here](http://docwiki.embarcadero.com/RADStudio/en/E2201_Need_imported_data_reference_($G)_to_access_'%25s'_from_unit_'%25s'_(Delphi)) how Embarcadero explains the E2201 issue. – menjaraz May 09 '12 at 06:30
  • @menjaraz `The requested page title was invalid, empty, or an incorrectly linked inter-language or inter-wiki title. It may contain one or more characters which cannot be used in titles. ` :( – PresleyDias May 09 '12 at 06:31
  • The info and the first fix attempt is also available [in this post](http://synopse.info/forum/viewtopic.php?pid=2850#p2850). – Arnaud Bouchez May 09 '12 at 06:33
  • Another link to the Embarcadero docs: http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/cm_package_varref_xml.html – Marjan Venema May 09 '12 at 07:31

1 Answers1

9

Why didn't you ask the question of the project forum?

A solution may enhance the official code of this Open Source unit.

OK - it may help me gain some SO points. ;)

AFAIK this "E2001" issue has already been identified - see this post and should have been fixed in the latest trunk. This is what sounds to work with Delphi 7, but not with Delphi 2006.

Here is a potential workaround of this compiler bug:

Define such a function:

function IconMessage(Icon: TTaskDialogIcon): string;
begin
  case Icon of
    tiWarning:   result := SMsgDlgWarning;
    tiQuestion:  result := SMsgDlgConfirm;
    tiError:     result := SMsgDlgError;
    tiInformation, tiShield: result := SMsgDlgInformation;
    else result := '';
  end;
end;

To be used as such:

if Inst='' then
  Inst := IconMessage(aDialogIcon);

This is now committed in the project trunk.

Thanks for using our Open Source component!

Arnaud Bouchez
  • 42,305
  • 3
  • 71
  • 159
  • hello, i tried the same link, even after following the steps i get the same problem – PresleyDias May 09 '12 at 06:25
  • @PresleyDias Did the function() modification still trigger the issue? It would be very confusing... – Arnaud Bouchez May 09 '12 at 06:33
  • hey [Latest SynTaskDialog](http://synopse.info/fossil/artifact/c21075ceb4b52444a05dc84c7c2debcf4d648328) works.!!!, i took the source and compiled and it works.. thank you – PresleyDias May 09 '12 at 06:39
  • i just noticed [Synopse framework. Copyright (C) 2012 Arnaud Bouchez]=[arnaud-bouchez](http://stackoverflow.com/users/458259/arnaud-bouchez) thank you for the great source :) – PresleyDias May 09 '12 at 06:40
  • @Arnaud Bouchez: I presume Latest SynTaskDialog means Version 1.16 at least and the issue to my understanding was adressed by the USEPACKAGES conditionnal, am I right? – menjaraz May 09 '12 at 06:57
  • @menjaraz No, the USEPACKAGES conditionnal is not used at all by SynTaskDialog, but by mORMot units, especially SynCommons. So setting USEPACKAGES conditionnal won't fix anything here. You'll have to use the latest version, using the function(), and not an array. – Arnaud Bouchez May 09 '12 at 07:31
  • FWIW: The `TD_ICONS_IDENT: array[TTaskDialogIcon] of string` solution works for me in D2007. I find it astonishing that it also works in D7 but **not** D2006. – Uli Gerhardt May 09 '12 at 09:51
  • D2006 was buggy, and D2007 is more or less a debugged version of D2006. In fact, this was the same for D7 (against D6) and D2010 (against D2009). With Borland/Embarcadero, some maintenance release are to be paid. :) – Arnaud Bouchez May 09 '12 at 11:49
  • @Arnaud. The function solution seems to have an additional advantage - see [this answer](http://stackoverflow.com/a/10513740/35162) (incl. comments) where it talks about localization. – Uli Gerhardt May 09 '12 at 12:25
  • @UlrichGerhardt I'm not sure localization will fail - the `array[] of string = (s...)` trick would fail, but the `LoadResStr` call would work as expected. In all cases, the previous trick did work if the i18n libraries will override `LoadResStr` implementation (which is e.g. done by GetText or the SQLite3i18n unit of our mORMot). And I suspect it did also work for pure-resource language package: the strings are loaded at runtime from the resource ID stored within the array[]. In all cases, the function performs well, and is just a bit more verbose. Compatibility is better, anyway. :) – Arnaud Bouchez May 10 '12 at 05:28