Joined: 01 Jul 2005
|Posted: Jan 25th, 2012, 1:12am Post subject: Call for examples
|I think there's enough documentation for about anybody to learn VFScript's syntax and semantics. What the docs miss the most are examples. I'm not the greatest when it comes to making simple, clear examples. If you can think up some interesting examples, I will give you due credit. Even when there's already an example, maybe you can come up with something better. Preferably an example should be as small as possible while getting across the essentials of the feature.
If you want to help, post your example in this topicc or double-click the section of the docs. When doing the former, please tell what feature the example demonstrates.
I will probably also be adding a section with a complete program or two. Below is my program that can translate English to Pig Latin. Feel free to discuss the merits of any submitted example.
PigLatin = ""
Prompt "Type some text you want in Pig Latin.", English
English = Trim(English)
If Len(English) = 0 Then
w = 1
EnWord = Word(English, w) & Space(1)
Do While Len(EnWord)
i = 1
Do Until InStr("aeiou ", Mid(EnWord, i, 1), , CaseIns)
i = i + 1
idxVowel = i
EnWord = Trim(EnWord)
If idxVowel > Len(EnWord) Then ' contains no vowels
PLWord = EnWord
ElseIf idxVowel > 1 Then ' starts w/ consonant(s)
PLWord = Mid(EnWord, idxVowel) & "-" & Left(EnWord, idxVowel - 1) & "ay"
Else ' starts w/ vowel
PLWord = EnWord & "-way"
PigLatin = PigLatin & PLWord & Space(1)
w = w + 1
EnWord = Word(English, w)
MsgBox PigLatin, "Pig Latin", "rc", pressed
Loop While pressed = 1