Sign in to follow this  
Followers 0
Prab

Char Shift

4 posts in this topic

Hi,

Does anyone know if there is a way to adjust a Char like in C? For example, I want to make "a" + 1 = "b". I tried this in MsgBox, but the only output was "1". I could write this in C (or maybe Java), but I want to show my CS teacher how powerful AutoIt is.

Thanks for your help.

Prab

Share this post


Link to post
Share on other sites



Hi,

Does anyone know if there is a way to adjust a Char like in C? For example, I want to make "a" + 1 = "b". I tried this in MsgBox, but the only output was "1". I could write this in C (or maybe Java), but I want to show my CS teacher how powerful AutoIt is.

Thanks for your help.

Prab

You could try this.

$b = chr(asc("a")+1)
MsgBox(0, "", $B)

Share this post


Link to post
Share on other sites

Thanks so much, that worked perfectly. Anyone willing to help debug an OB1 error?

#include <Array.au3>

$file = FileOpen("test.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

; Read in 1 character at a time until the EOF is reached
$chars = ""
While 1
    $chars &= FileRead($file, 1)
    If @error = -1 Then ExitLoop
Wend

MsgBox(0, "Input String: ", $chars)

Local $answerArray[1]
$answerArray[0] = $chars

For $x = 1 To 25;cycle through all possiblities in the alphabet.
    $newString = ""
    For $y = 0 To StringLen($chars) - 1;convert all letters in the string
        $tempChar = StringMid($chars, $y + 1, 1)
        If $tempChar = "z" Then $tempChar = "a"; only work with "a" through "z"
        If StringIsAlNum($tempChar) Then
            $adjustedChar = Chr(asc($tempChar)+1)
        Else
            $adjustedChar = " ";leave spaces alone
        EndIf
        $newString &= $adjustedChar
    Next
    _ArrayAdd($answerArray, $newString)
    $chars = $newString
Next
_ArrayDisplay($answerArray)

FileClose($file)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0