import re

def convert_atari_basic(input_file, output_file):
    with open(input_file, 'r') as f:
        lines = f.readlines()

    with open(output_file, 'w') as f:
        for line in lines:
            # Use regular expression to find string assignments with LOC$= and RE$=
            matches = re.findall(r'(LOC\$|RE\$)="?([A-Z\s.]+)"?', line)
            for match in matches:
                variable_name, string_value = match
                # Convert the string to the desired format
                converted_string = ""
                capitalize_next = True
                for char in string_value:
                    if char == '.':
                        capitalize_next = True
                        converted_string += char + " "
                    elif capitalize_next:
                        converted_string += char.upper()
                        capitalize_next = False
                    else:
                        converted_string += char.lower()
                # Replace the original string with the converted version
                line = line.replace(string_value, converted_string, 1)
            f.write(line)

if __name__ == "__main__":
    input_file = input("Enter input file name: ")
    output_file = input("Enter output file name: ")
    convert_atari_basic(input_file, output_file)
    print("Conversion complete.")
