Vp string: Difference between revisions

From Virtual Paradise Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{sdk method page|string|Return a pointer to string attribute.
{{sdk method page|string|Return the value of a string attribute.
|paramex=attr
|paramex=attr
|parameters=
|parameters=
   {{sdk parameter row|vp_string_attribute_t|attr|Attribute to return value of}}
   {{sdk parameter row|vp_string_attribute_t|attr|Attribute to return value of (defined in VP.h)}}
|returns=
|returns=
  const char*
The value of the attribute.
|behavior=
|behavior=If an invalid identifier is passed for <i>attr</i>, then a pointer to "" (empty string) will be returned.
|caveats=If an invalid value is passed for attr, then a pointer to "" will be returned.
|caveats=There is no way to know if the call was unsuccessful, use {{sdk method|string_get}} when this is required.
|examples=
|examples=
<syntaxhighlight lang="c">
void handle_avatar_add(VPInstance sdk)
{
  char msg[256];
  sprintf(msg, "Welcome %s to the world!", vp_string(sdk, VP_AVATAR_NAME));
  vp_say(sdk, msg);
}
int main(int argc, const char* argv[])
{
  //...
  vp_event_set(sdk, VP_EVENT_AVATAR_ADD, handle_avatar_add);
  //...
}
</syntaxhighlight>
|seealso=
|seealso=
* {{sdk method|string_get}}
* {{sdk method|string_get}}
* {{sdk method|string_set}}
* {{sdk method|string_set}}
}}
}}

Latest revision as of 22:11, 13 December 2016

Method call snippet vp_string(instance, attr);

Return the value of a string attribute.

Parameters

These are the parameters that this method requires:

Parameter Usage
VPInstance
instance
Pointer to the instance this method call is intended for
vp_string_attribute_t
attr
Attribute to return value of (defined in VP.h)

Returns

The value of the attribute.

Behavior

If an invalid identifier is passed for attr, then a pointer to "" (empty string) will be returned.

Caveats

There is no way to know if the call was unsuccessful, use vp_string_get() when this is required.

Examples

void handle_avatar_add(VPInstance sdk)
{
  char msg[256];

  sprintf(msg, "Welcome %s to the world!", vp_string(sdk, VP_AVATAR_NAME));
  vp_say(sdk, msg);
}

int main(int argc, const char* argv[])
{

  //...

  vp_event_set(sdk, VP_EVENT_AVATAR_ADD, handle_avatar_add);

  //...
}

See also