Thread

VB Error Question (Sdk)

VB Error Question // Sdk

1  |  

cozmo

Oct 13, 2001, 10:04pm
What does: "Assignment to constant not permitted", mean?

The highlighted code is:


sdk1 <Hightlight> .AwWhisper(PLAYER_ID, WELCOME_MESSAGE_NEWPLAYER) =
</Highlight> True

PLAYER_ID = sdk1.AwAvatarSession (set as Long)
WELCOME_MESSAGE_NEWPLAYER = (a string read from an ini file) (set as String)

--
- Cozmo Of Cozmo-X
http://cozmo-x.zapto.org
World: A'Dude

young phalpha

Oct 14, 2001, 12:40am
Its highly evident that your attempting to set a function to something, or is it in an if? I can
tell this without knowing a lick of VB :)

[View Quote] The highlighted code is:


sdk1 <Hightlight> .AwWhisper(PLAYER_ID, WELCOME_MESSAGE_NEWPLAYER) =
</Highlight> True

PLAYER_ID = sdk1.AwAvatarSession (set as Long)
WELCOME_MESSAGE_NEWPLAYER = (a string read from an ini file) (set as String)

--
- Cozmo Of Cozmo-X
http://cozmo-x.zapto.org
World: A'Dude

cozmo

Oct 14, 2001, 1:32am
no this is under the avataradd event.....

[View Quote]

young phalpha

Oct 14, 2001, 1:50am
Well then it does appear your attempting to set a function as if it were a varible...

[View Quote] [View Quote]

ananas

Oct 14, 2001, 2:11am
no VB knowledge but here's my idea from C :

A constant is a constant value that can only be set from
values that can be evaluated at compile time. Simple
calculations that are evaluated from other constants
are values like that.

Everything that might change its value in any runtime
operation (function results are evaluated at runtime)
always has to be a variable instead of a constant.

If either PLAYER_ID or WELCOME_MESSAGE_NEWPLAYER are
declared constant, the compiler will not allow changes
on runtime. Usually all-uppercase names are used for
constants, to make clear that these cannot be used on
the left side of the "equals"-operator.

[View Quote] --
"_
|
/\
\ /
__/ /_

cozmo

Oct 14, 2001, 3:41am
i always make my variables in caps to make them stand out....and no all i
did for them was Dim PLAYER_ID As Long and so on

[View Quote]

ananas

Oct 14, 2001, 4:23am
oh, now I understand this hilite stuff - if I take it out
I can read the code and see the error in it (I guess).

You assign a value to a function !

sdk1.AwWhisper(PLAYER_ID, WELCOME_MESSAGE_NEWPLAYER) = True

A function isn't a good L-Value, not useable for the left side
of the equals sign

just a hint :
You should consult a styleguide sometimes ;)

[View Quote] --
"_
|
/\
\ /
__/ /_

kah

Oct 14, 2001, 8:51am
what's the deal with the = True? has nothing at all to do with .AwWhisper, I
don't see why you added it

KAH

[View Quote]

cozmo

Oct 14, 2001, 2:20pm
if i dont use it it errors me saying i need an = and some value.....i have
always done this becuase it wont let me do otherwise and it usually
works.....basicly the true means DO IT

[View Quote]

ananas

Oct 14, 2001, 4:38pm
Maybe VB requires that a return value of a function is
always used? AwWhisper is declared as a function returning
a longint value, that would be :


Dim DummyLong As Long

DummyLong = sdk1.AwWhisper(PLAYER_ID, WELCOME_MESSAGE_NEWPLAYER)


optional :

If (sdk1.AwWhisper(PLAYER_ID, WELCOME_MESSAGE_NEWPLAYER) > 0) Then
Begin <= just an empty statement here, ...
End <= ... I guess in VB it looks like this


[View Quote] --
"_
|
/\
\ /
__/ /_

baron

Oct 14, 2001, 4:41pm
For the use of aw_whisper check the documentation, you can't assign a value to a method:
http://www.activeworlds.com/sdk/aw_whisper.htm
http://www.grimmsoft.com/help/index.php?parent=1&item=59&expand=2

On this case just lose the parenthesis:
sdk1.AwWhisper PLAYER_ID, WELCOME_MESSAGE_NEWPLAYER
or if you insist on saying "do it" use:
Call sdk1.AwWhisper (PLAYER_ID, WELCOME_MESSAGE_NEWPLAYER)

Baron


[View Quote]

cozmo

Oct 14, 2001, 4:46pm
oooohhhh.....thats like the rc thing isnt it? mrgrimm used that in soem
other ones and its like the error code or something....well anyways i get it
now

[View Quote]

lanezeri

Oct 14, 2001, 6:04pm
Nope..

sdk1.AwWhisper(PLAYER_ID, WELCOME_MESSAGE_NEWPLAYER) = True

You get an error for the missing equals sign because you have it in ( ). If
you would just have:

sdk1.AwWhisper PLAYER_ID, WELCOME_MESSAGE_NEWPLAYER

It would work perfectly fine. :-)

--

Lanezeri
Lead Bot Programmer at Stuff-X
http://aw.stuff-x.com


[View Quote]

grimble

Oct 14, 2001, 11:31pm
.... or, if you like neatly, consistent formed code for both functions and
procedures, then use Call ...

Call sdk1.AwWhisper(PLAYER_ID, WELCOME_MESSAGE_NEWPLAYER)



[View Quote]

grimble

Oct 14, 2001, 11:33pm
Sorry ... Baron already said that.

[View Quote]

1  |  
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn