Let's say I have a variable:
Code: Select all
$ variable = "abcdefgabc"
Additionally, how can I modify "$ variable" so that it no longer is "abcdefgabc", but is now "cde" WITHOUT manually overwriting it by outright saying:
Code: Select all
$ variable = "cde"
Code: Select all
$ firstname = "Johnathon"
$ lastname = "Smith"
$ fullname = firstname + " " + lastname
Then, let's say I want Millie to refer to Smith by the 4th through 7th letters, resulting in a nickname of "Nath". In theory, this seems like it'd work similarly to with Tina, Create a variable ("$ MillieCalls") and have the output of "nath" be it's value, but this then has an issue... "nath" and "Nath" are not the same. The first letter needs capitalized. So, to do this, I would need a way of "viewing" the first symbol in the variable's value (the "n" in "nath"), copying it into its own variable ($ symbol1 = "n"), removing the "n" from "nath", having the program replace the lowercase "n" with an uppercase "N" (See: Code Block A), then having the program concatenate "N" with "ath" (See: Code Block B).
Code: Select all
### CODE BLOCK A
if $ symbol1 == "a":
$ symbol2 = "A"
if $ symbol1 == "b":
$ symbol2 = "B"
if $ symbol1 == "c":
$ symbol2 = "C"
## . . .
if $ symbol1 == "n":
$ symbol2 = "N"
## . . .
Code: Select all
### CODE BLOCK B
## MillieCalls should equal "ath" presuming the name "Johnathon" was chosen.
$ MillieCalls = symbol2 + MillieCalls
I know the rule is one question per thread. Maybe you'll see this differently, but I see this as one question: "How to manipulate variable values?" I am trying to make this project so that there is a degree of personality behind it to help with immersion and to give a bit of quirkiness to the characters. While this isn't exactly how the code will be used, this gives an accurate idea of what I need the code to do so that I can get my project going the way I want it to. I don't want to give specifics on my project because I don't want to announce progress on something that may ultimately fail to be completed for one reason or another, but I know I could use this information in any project I work on and I am sure it could help others. I'm sorry for the weird question, but I hope you understand!
Sorry for the inconvenience
~Arcial