Πέμπτη 4 Ιουνίου 2026

SubScript and SuperScript Numbers

This is an example to print subscript/superscript numbers.

Need the latest version or use @SubScript() and @SupScript() for calling simple functions

Module SupSub_Script_Example {
  If Mode<>22 then font "Arial New": Mode 22
  Locale 1033 ' works for 1032 too
  Print Part "A";SupScript(-12345.06789e-100)
  Print
  N=12
  Print Part "C";SubScript(N);"H";SubScript(2*N+2)
  Print
  Print Part "Rational = ";SupScript(123);"/";SubScript(456)
  Print
  Print Part "Just Subscript = A";SubScript(-12345.06789e-100)
  Print
  Function SubScript(x)
    local string r
    local s=""+x, i
    for i=1 to len(s)
      n=val(mid$(s,i,1))
      select case mid$(s,i,1)
      case "E"
        r+=chrcode$(0x1D07 ) '  chrcode$(0x1D49)
      case ","
        r+=","
      case "."
        r+="."  
      case "-"
        r+=chrcode$(0x208B)
      case "+"
        r+=chrcode$(0x208a)
      case else
        r+=chrcode$(0x2080+n)
      end select
    next
    =r
  End Function
  Function SupScript(x)
    local string r
    local s=""+x, i
    for i=1 to len(s)
      n=val(mid$(s,i,1))
      select case mid$(s,i,1)
      case "1"
        r+=chrcode$(0x00B9)
      case "2","3"
        r+=chrcode$(0x00B0+n)
      case "E"
        r+=chrcode$(0x1D31 ) '  chrcode$(0x1D49)
      case ","
        r+=chrcode$(0x02D2)
      case "."
        r+=chrcode$(0x22C5)    
      case "-"
        r+=chrcode$(0x207b)
      case "+"
        r+=chrcode$(0x207a)
      case else
        r+=chrcode$(0x2070+n)
      end select
    next
    =r
  End Function
}
SupSub_Script_Example