ThreadBoard ArchivesSite FeaturesActiveworlds SupportHistoric Archives |
some help needed (Sdk)
some help needed // SdkroluMar 8, 1999, 11:29am
Hi, I started to program with the SDK last night, and I ran into some
questions. I use Delphi 4. 1. in these C++ programs I see things like: if (rc = aw_init (AW_BUILD)) { printf ("Unable to initialize API (reason %d)\n", rc); exit (1); } Am I right in trying to translate this into rc:=aw_init(AW_BUILD); if rc=0 then messages.lines.add('API initialized succesfully') //messages is a memo box else begin messages.lines.add('Failed to initialize API'); exit; end; This seems to work correctly, but I'm not sure. And how can I use the %d? 2. I tried to make my bot say something with aw_say('[beep]'); it should have said [beep] but it said nothing. Rolu andras sarkozyMar 8, 1999, 6:55pm
[View Quote]
> Hi, I started to program with the SDK last night, and I ran into some
> questions. > > I use Delphi 4. > > 1. > in these C++ programs I see things like: > > if (rc = aw_init (AW_BUILD)) { > printf ("Unable to initialize API (reason %d)\n", rc); exit (1); } > > Am I right in trying to translate this into > > rc:=aw_init(AW_BUILD); > if rc=0 then > messages.lines.add('API initialized succesfully') //messages is a > memo box > else > begin > messages.lines.add('Failed to initialize API'); > exit; > end; > > This seems to work correctly, but I'm not sure. And how can I use the %d? messages.lines.add("Faied to initialize API reason=%d",rc); <I guess it is still valid in Delphi> > > > 2. > I tried to make my bot say something with > > aw_say('[beep]'); > > it should have said [beep] but it said nothing. > > Rolu Aren't you supposed to use text quotes? (aw_say("[beep]");) "'" used to quote characters only in "C". Again I'm not a Delphi expert, but coming from "C" it seems obvious. Andras netropolisMar 8, 1999, 6:57pm
[View Quote]
messages.lines.add(Format('blah blah.. reason code: %d', [rc]));
> 2. > I tried to make my bot say something with > > aw_say('[beep]'); > > it should have said [beep] but it said nothing. > is the bot instance created correctly? is it logged into the universe and logged into any world? did it announce its position in the world? -Netro canopusMar 8, 1999, 10:34pm
There are versions of the Sample Programs in the Delphi threads for 10/1/98 and
10/13/98. They stick as close as possible to the C code of the original Sample Programs, so that you can easily see what has to be modified to work in Delphi. Some of your questions will be answered there. Most of the Delphi threads since that time are clearly labeled; if you want to work with a Delphi encapsulation of the SDK, see the 2/13/99 thread. For example, in Sample 1, the Greeter Bot uses aw_say with the string parameter (in single quotes, as usual) converted from a Delphi string to a C string by a PChar typecast (in the line before the call to aw_say). The encapsulated versions of the Sample Programs allow you to ignore details like how and when aw_init is called; it already has a unit containing resource strings for the reason codes, and to log them to your memo, all you have to do is to enable the BotMaster object's Reason method and direct its Reason output to your memo control. [View Quote] > Hi, I started to program with the SDK last night, and I ran into some > questions. > > I use Delphi 4. > > 1. > in these C++ programs I see things like: > > if (rc = aw_init (AW_BUILD)) { > printf ("Unable to initialize API (reason %d)\n", rc); exit (1); } > > Am I right in trying to translate this into > > rc:=aw_init(AW_BUILD); > if rc=0 then > messages.lines.add('API initialized succesfully') //messages is a > memo box > else > begin > messages.lines.add('Failed to initialize API'); > exit; > end; > > This seems to work correctly, but I'm not sure. And how can I use the %d? > > 2. > I tried to make my bot say something with > > aw_say('[beep]'); > > it should have said [beep] but it said nothing. > > Rolu |