Es.format

From EventScripts Community Encyclopedia
This article is a stub. Please help by adding to it.



Method: format

Module: es
Class: (no class)
EventScripts version: 2.0

Method Overview

Table of Contents

Contents


Description

  • Note : This is depreciated in favour of native python string formatting

Formats a string according to the format-string and stores it into the variable command.

Arguments

<variable> <format-string> [token1] [token2] [token3] [...] [token9]

  • variable - Variable to store the string into.
  • format-string - String that you would like to place the parameters into. Will place tokenX in format-string in place of %X.
  • tokenX - Tokens that will be placed in the string. Can have any number of tokens from 0 to 9.


Examples

# es.format
es.set('mystring', '')
es.set('myvar1', 'love')
es.set('myvar2', 'EventScripts')
es.format('mystring', 'Dont you just %1 %2?', str(es.ServerVar('myvar1')), str(es.ServerVar('myvar2')))
es.msg(str(es.ServerVar('mystring'))
 
# Outputs: Dont you just love EventScripts?
 
# Native string formatting in python:
myvar1 = 'love'
myvar2 = 'EventScripts'
mystring = 'Dont you just %s %s?'%(myvar1, myvar2)
es.msg(mystring)
 
# Outputs: Dont you just love EventScripts? 

Notes

This is depreciated in favour of native python string formatting (see above for example/comparison)

See Also

blog comments powered by Disqus