| View previous topic :: View next topic |
| Author |
Message |
Xanatos I post too much
Reputation: 18
Joined: 06 May 2007 Posts: 2559 Location: US
|
Posted: Sun Aug 05, 2007 1:22 pm Post subject: [issue] [Delphi] incompatible types. |
|
|
Okay I'm using a function that is included in Delphi to get and set a variable from an online Flash game. Here is the part of the code:
| Code: | procedure TForm1.ItemTimer(Sender: TObject);
begin
try
DF.GetVariable('_loc2');
DF.SetVariable('_loc2', 'I want to put a number here');
Except
end;
end; |
Now the problem is I can only seem to set the variable _loc2 to a String's value, not a integer etc.
If I try that, I get an incompatible types error on compiling, and if I ran it with a String type data, I get a logical/runtime error. The game seems to have error handling and handles whatever I set it to as NaN. Also InttoStr doesn't work, I've tried it.
Is there any way to set this to an integer? I've looked at some stuff on Google, but the best I got is the "is" and "as" operator.
And if the solution involves somehow overloading the function to include other types of input, I'll need some serious help . _________________
Last edited by Xanatos on Sun Aug 05, 2007 1:32 pm; edited 1 time in total |
|
| Back to top |
|
 |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Sun Aug 05, 2007 1:27 pm Post subject: |
|
|
| IntToStr |
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sun Aug 05, 2007 1:30 pm Post subject: |
|
|
try
IntToStr(edit1.text);
for a text box to set the value
if u just want a number then
IntToStr('number'); |
|
| Back to top |
|
 |
Xanatos I post too much
Reputation: 18
Joined: 06 May 2007 Posts: 2559 Location: US
|
Posted: Sun Aug 05, 2007 1:31 pm Post subject: |
|
|
InttoStr doesn't work (i'm not a complete retard)
The function will still give me an error, and I know how to use that. _________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sun Aug 05, 2007 1:32 pm Post subject: |
|
|
| what error? |
|
| Back to top |
|
 |
Xanatos I post too much
Reputation: 18
Joined: 06 May 2007 Posts: 2559 Location: US
|
Posted: Sun Aug 05, 2007 1:33 pm Post subject: |
|
|
Incompatible types. Again. _________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sun Aug 05, 2007 1:38 pm Post subject: |
|
|
wierd...
i put it in my procedure and it works...
i put this, with the value 33 and it work...
try
DF.GetVariable('_loc2');
DF.SetVariable('_loc2', '33');
Except
end;
what is df, its a shockwaveflash?
maybe u named it something else.. check |
|
| Back to top |
|
 |
Xanatos I post too much
Reputation: 18
Joined: 06 May 2007 Posts: 2559 Location: US
|
Posted: Sun Aug 05, 2007 1:40 pm Post subject: |
|
|
Yeah, but won't that change it to a String?
Because there are quotes around the 33.
Also yes, DF is a shockwaveflash, and everything works peachy when I put in a string -.-. _________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sun Aug 05, 2007 1:48 pm Post subject: |
|
|
umm try
try
DF.GetVariable('_loc2');
DF.SetVariable('_loc2', edit1.Text);
Except
end;
?
if u dont want to use a text box use label1.caption and make it invisibe? |
|
| Back to top |
|
 |
Xanatos I post too much
Reputation: 18
Joined: 06 May 2007 Posts: 2559 Location: US
|
Posted: Sun Aug 05, 2007 1:49 pm Post subject: |
|
|
| Symbol wrote: | umm try
try
DF.GetVariable('_loc2');
DF.SetVariable('_loc2', edit1.Text);
Except
end;
?
if u dont want to use a text box use label1.caption and make it invisibe? |
Caption and Text are also String types, I need integers.
And yes... I tried text. (I'll try caption for the heck of it). _________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sun Aug 05, 2007 1:53 pm Post subject: |
|
|
but if u type a number?
try using variables i guess there are few was to do it with vars... |
|
| Back to top |
|
 |
Xanatos I post too much
Reputation: 18
Joined: 06 May 2007 Posts: 2559 Location: US
|
Posted: Sun Aug 05, 2007 1:56 pm Post subject: |
|
|
| Symbol wrote: | but if u type a number?
try using variables i guess there are few was to do it with vars... |
Again won't work . The function only allows widestring types. So is there another one I can use to set that var? _________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sun Aug 05, 2007 1:58 pm Post subject: |
|
|
why not using a string then...?
i dont know much about shockwaves trainers.. sorry =\ |
|
| Back to top |
|
 |
Xanatos I post too much
Reputation: 18
Joined: 06 May 2007 Posts: 2559 Location: US
|
Posted: Sun Aug 05, 2007 2:01 pm Post subject: |
|
|
| Symbol wrote: | why not using a string then...?
i dont know much about shockwaves trainers.. sorry =\ |
Strings are handled as NaN, and there the variable I'm trying to change will allow to me chose what item is generated when I complete a quest. And there isn't an item ID for NaN . _________________
|
|
| Back to top |
|
 |
compactwater I post too much
Reputation: 8
Joined: 02 Aug 2006 Posts: 3923
|
Posted: Sun Aug 05, 2007 2:31 pm Post subject: |
|
|
It's passed as a WideString I believe, so put '1000' not 1000.
It would be the same thing.
If you can't get the variable, that means it doesn't exist, or doesn't exist yet. |
|
| Back to top |
|
 |
|