This is an old revision of the document!


The Scripting Language

Limitations and features

The Nettalk-language script uses the same syntax as other Visual Basic dialects. However there are some limitations to note:

  • You can not have multiple commands with a colon in a separate line.
  • There is on the Do / Loop construct for iterating around a piece of script (ie the For / Next statements are not available)
  • There is no static declaration of variables.
  • As with VB Script, there is only one universal variable type (known as a variant). After the declaring a variable using Dim it will be an empty string.
  • There are no line numbers.
  • Arrays are only one-dimensional, they are not declared and are valid throughout the script part (a section marked by #NewScriptBegin). Instead of a numeric index a string key can also be used.

Examples

Procedures and variables

#NewScriptBegin Script1
 
'Variable Testvar1 available in Script1
Dim Testvar1
 
'Variable Testvar2 available in all scripts
Public Testvar2
 
Sub StartTest()
  Testvar1="Test-Text"
  Testvar2="More Test-Text"
  MsgBox "Test2 in Script1"
 
  'Call Test1 in Script1
  Test1
 
  'Call Test1 in Script2
  Script2.Test1
End Sub
 
Sub Test1()
  MsgBox "Test1 in Script1 (" + Testvar1 + ")"
End Sub
 
 
#NewScriptBegin Script2
 
Sub Test1()
  MsgBox "Test1 in Script2 (" + Testvar2 + ")"
End Sub

Functions and variables

#NewScriptBegin Script1
 
Sub StartTest()
  MsgBox "Test2 in Script1"
 
  'call Test1 in Script1
  Test1 "Burt", "Fred"
 
  'call Test1 in Script2
  TempText = Script2.Test1("Test...")
 
  MsgBox TempText
End Sub
 
Sub Test1(Text1, Text2)
  MsgBox "Test1 in Script1 (" + Text1+ " and " + Text2 + ")"
End Sub
 
 
#NewScriptBegin Script2
 
Function Test1(Text)
  Test1 = "Text from Test1 in Script2 (" + UCase(Text) + ")"
End Sub

Aufrufen von Scriptteilen

Um Prozeduren und Funktionen per Hand in Nettalk aufzurufen gibt es den Befehl /call, /calc oder einfach ein ”?”.

Folgende drei Aufrufe bewirken alle das Selbe:

/call Test1 Hanz Egon

/calc Test1("Hanz", "Egon")

?Test1("Hanz", "Egon")

Wie man sieht kann das ”?” genau wie /calc verwendet werden. Besonderheiten von ”?” sind die Modifikationen ”?#” und ”?@”. Während das einfache ”?” den Rückgabewert einer Funktion nur dem Benutzer anzeigt, versendet ”?#” den Rückgabewert und ”?@” versendet den Rückgabewert mit dem Funktionsaufruf. Beispiele:

?@Test1("Hanz", Str(32*1024))
?5+8
?#5+2^8
/calc 7*7+5

Da dem Befehl /call die Argumente ohne Anführungszeichen angegeben werden, kann maximal ein String mit Leerzeichen übergeben werden in dem dieser durch ein ”:” markiert wird. Zudem zeigt /call keine Rückgabewerte an. Beispiel für einen String mit Leerzeichen:

/call Test3 Hanz Egon Marta :Dies ist ein Texttext mit Leerzeichen




Original German content : Die Scriptsprache


Personal Tools