# LoadError: LoadError: UndefVarError: ASCIIString not defined

**URL:** <https://discourse.julialang.org/t/loaderror-loaderror-undefvarerror-asciistring-not-defined/58885>\
**Category:** General Usage\
**Tags:** package\
**Created:** [April 8, 2021, 10:50pm UTC](https://discourse.julialang.org/t/loaderror-loaderror-undefvarerror-asciistring-not-defined/58885 "2021-04-08T22:50:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SudhakarKuma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sudhakarkuma/32/23800_2.png) [@SudhakarKuma](https://discourse.julialang.org/u/SudhakarKuma)\
**Post date:** [April 8, 2021, 10:50pm UTC](https://discourse.julialang.org/t/loaderror-loaderror-undefvarerror-asciistring-not-defined/58885/1 "2021-04-08T22:50:18Z")

</div>

Hello everyone! I have a function (as given below) in Julia that was working for **Julia 0.4.5**.

```julia
function pinMode(file_des::SerialPorts.SerialPort , pin_no::Int64 , mode::ASCIIString)
  m = uppercase(mode) # Prevent errors due to case differences
  if m == "INPUT" str = "Da"*string(Char(48+pin_no))*"0" end # Dan0 for INPUT
  if m == "OUTPUT" str = "Da"*string(Char(48+pin_no))*"1" end # Dan1 for OUTPUT
  str = ascii(str) # Converts UTF8String to ASCIIString
  write(file_des,str)
end

```

Now, I have **Julia 1.6.0** on my machine. As expected, the above-mentioned function is not working on this new Julia. While running this function on **Julia 1.6.0** , we get an error, as shown below.

> LoadError: LoadError: UndefVarError: ASCIIString not defined

I came to know that **ASCIIString** no longer exists in Base, as given on [ASCIIString not defined](https://discourse.julialang.org/t/asciistring-not-defined/9570). On this website, I also found that one can use **LegacyStrings** package to use **ASCIIString**. I tried using this package and called **LegacyStrings.ASCIIString** instead of **ASCIIString** in the above-mentioned function. However, it didn’t work and later, I realized that **LegacyStrings.jl** package had not been updated for v0.7/master yet. Could you please help me with how to use **ASCIIString** in the above-mentioned function on **Julia 1.6.0**?

Thanking you in anticipation,

Regards,  
Sudhakar

---

<div class="post-metadata">

**Author:** ![aramirezreyes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aramirezreyes/32/42573_2.png) [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)\
**Post date:** [April 8, 2021, 11:01pm UTC](https://discourse.julialang.org/t/loaderror-loaderror-undefvarerror-asciistring-not-defined/58885/2 "2021-04-08T23:01:12Z")

</div>

The reply on the post you link to is probably the best answer:

> [@ASCIIString not defined](https://discourse.julialang.org/t/asciistring-not-defined/9570/2):
>
> ASCIIString no longer exists in Base, so you are apparently using code from Julia 0.4 or earlier — it will need to be updated in several ways, probably. Just use the String, k.captures[1]. If you need to check that it is ASCII, use isascii. In the rare cases where you actually need an ASCIIString type, you can use the LegacyStrings package. Note that to upgrade code from an “ancient” version like Julia 0.4, it is best to first upgrade it to Julia 0.5, then upgrade it to Julia 0.6. This wa…

I encourage yo to try and work without ASCIISTRING. For example, as proposed in the answer, you could just use String and check if the string is ascii inside the function

```julia
function pinMode(file_des::SerialPorts.SerialPort , pin_no::Int64 , mode::String)
!isascii(mode) && throw("Mode needs to be ascii") #This will throw an error if mode is not ascii
  m = uppercase(mode) # Prevent errors due to case differences
  if m == "INPUT" str = "Da"*string(Char(48+pin_no))*"0" end # Dan0 for INPUT
  if m == "OUTPUT" str = "Da"*string(Char(48+pin_no))*"1" end # Dan1 for OUTPUT
  str = ascii(str) # Converts UTF8String to ASCIIString
  write(file_des,str)
end

```

If your code is composed of more functions, probably updating first to v0.5, then to v0.6 and v0.7. In particular v0.7 will tell you a lot of deprecation warnings to help you get your code ready for Julia v1.6
