[Little Helper] multiline string converter

Hey folks,

one of our devs made a little page where you can convert your multi-line-strings into a xojo-like-multiline-string.

As you know in xoxo multi-line string are written like

dim str as string = "123456" +_ "12344678" +_ "09876789"

Our little page converts a regular text into a xojo-inline-string.

Feel free to use it.

http://dev.stadtlandnetz.de/tools/string_validator.htm

1 Like

Very nifty. But I would welcome this as desktop app.

So it does not like me, only me ?
(it does not split my line, my lines)

[quote=396083:@Emile Schwarz]So it does not like me, only me ?
(it does not split my line, my lines)[/quote]

you have to press tab after pasting your text.

You can do this with an IDE script:

[code]
Dim EOL As String = chr(13)
Dim sa() As String = split(clipboard, EOL)
For i As Integer = 0 To UBound(sa)
sa(i) = replaceall(sa(i), chr(34), chr(34) + chr(34))
sa(i) = chr(34) + sa(i) + chr(34)
Next

Dim s As String = join(sa, " + _ " + endofline)
seltext = s[/code]

Will insert whatever is on your clipboard directly into the current code editor with quotes doubled and each line quoted and separated by + _.

A click in the window copy my text example in the right area.

It uses jQuery and Javascript. Do you allow executing JS?

You can act on selected text in the IDE too if you don’t want to go through the clipboard. My “scramble” script does that.

Edit: I should have said, my “obfuscate” or “obfuscation” script does that.

Well, it doesn’t handle the quotes…

[quote]I’d like to know: “Is that correct?”
I guess not…[/quote]
becomes

"I'd like to know: "Is that correct?"" +_ "I guess not..."
So one can’t use that to put in “a regular text” and use it as a “xojo string”.

I find IDE scripts very unhandy, since you always have to load it from external.

Having such a small converter open in a tab of my browser (which is also always open), is for me a better way.

Ahem, no?!

Found here: http://developer.xojo.com/userguide/ide-scripting

[quote=396101:@Lars Lehmann]I find IDE scripts very unhandy, since you always have to load it from external.

Having such a small converter open in a tab of my browser (which is also always open), is for me a better way.[/quote]
Just put them in the Scripts folder next to the IDE or your project and they’ll appear in the File > IDE Scripts menu.

It turns out I have a script like this, just didn’t remember. Written a long time ago, apparently, so forgive any deficiencies.

const kWrapWidth = 80

Function PosOfLastNonWordChar(s As String, endPos As Integer) As Integer
  dim pos as integer = endPos
  dim unicodeChars as string = "_"
  
  dim chars() as string = s.Split("")
  for i as integer = endPos DownTo 1
    dim char as string = chars(i - 1)
    
    if char >= "A" and char <= "Z" then
      // Keep going
    elseif char >= "0" and char <= "9" then
      // Keep going
    elseif unicodeChars.InStr(char) <> 0 then
      // Keep going
    else
      pos = i
      exit
    end if
  next i
  
  return pos
End Function

dim s as string = SelText
if s = "" then
  print "Select some text first."
  return
end if

const kQuote = """"

dim addOpenQuote as boolean
dim addCloseQuote as boolean

if s.Left(1) = kQuote then
  s = s.Left(2)
  addOpenQuote = true
end if
if s.Right(1) = kQuote then
  s = s.Left(s.Len - 1)
  addCloseQuote = true
end if

dim stack() as string
while s.Len > kWrapWidth
  dim pos as integer = PosOfLastNonWordChar(s, kWrapWidth)
  
  stack.Append s.Left(pos)
  s = s.Mid(pos + 1)
wend
stack.Append s

s = join(stack, kQuote + " + _" + EndOfLine + kQuote)
if addOpenQuote then
  s = kQuote + s
end if
if addCloseQuote then
  s = s + kQuote
end if

SelText = s
if not addCloseQuote then
  SelStart = SelStart + 1
end if

I do not know. I suppose not.