Wrapping API2 questions

If I have

MessageBox String.FromArray( aStringArray, ",")

and do

Public Function FromArray(extends s as String, sourceArray() as String, Delimiter as String) as String
    return Join( sourceArray, Delimiter )
End Function

I get

"Parameter s expects type String, but this is type No type."

How do I deal with that???

Hmmm, might be able to use an IDE script for this … just have to figure out how to use an IDE script

NOPE! Far too limited. Can’t even do a “search/replace all”.

But a few simple manual search/replace should do it. …

Is string defined as a variable ?
extends takes an variable not a type name or module name

ie/ this should work

dim s as string
MessageBox s.FromArray( aStringArray, ",")

But in order for String.FromArray to work it would not be an extends and it would need to be in a module called String with a param list like

Public Function FromArray(sourceArray() as String, Delimiter as String) as String
    return Join( sourceArray, Delimiter )
End Function

I actually had tried that but no luck. The bit of code where I saw this was the OP of ReplaceLineEndings from ClipBoard text with EndOfLine.Windows - General - Xojo Programming Forum

See the last line:

Dim TampText, TampTab(-1) as String
Dim PressPap as New Clipboard

If Keyboard.AsyncAltKey and PressPap.TextAvailable Then
  TampText = PressPap.Text
Else
  TampText = "Line 1" + EndOfLine.Windows + "Line 2" + EndOfLine.Windows + "Line 3"
  MessageBox "copy the 3 lines below on the clipboard :" + EndOfLine + TampText
End If
TampText = TampText.ReplaceLineEndings(EndOfLine.macOS)
TampTab = TampText.Split(EndOfLine.macOS)
MessageBox "Count of items = " + str(TampTab.Count) + EndOfLine + String.FromArray(TampTab, "<-->")

The IDE probably prevents you from creating a module called String ?
This goes back to my post about working around things the IDE prevents

What version are you using ? As there may be other reasons why this wont work
It may be there already IS a string module so you can’t define a new one

EDIT - if you using 2018r4 then there IS already a module in the framework called String so you cannot define your own string module
Basically you CANT make this work in any version that already has a string module already

The IDE probably prevents you from creating a module called String ?

Yup.

This goes back to my post about working around things the IDE prevents

Will have a look.

What version are you using ? As there may be other reasons why this wont work
It may be there already IS a string module so you can’t define a new one

2018R3 is the last version covered by my license. Guess my next license might be when API2, Web2, and Android are considered stable … unless I have defected by then ….

EDIT - if you using 2018r4 then there IS already a module in the framework called String so you cannot define your own string module
Basically you CANT make this work in any version that already has a string module already

How can you see if a version has a String module already?

Unfortunately

will stop you dead :frowning:

its why I requested feedback://showreport?report_id=60412

sometimes you can write code that assumes one
I tried

    dim t as text = string.totext("123")

and the message I got is one that doesnt say “String” as a module doesnt exist but that ToText is an extension method - which means it is an extension method IN the String module.
There are other ways too

Thanks. Well, for now I’m going with Search / Replace for the instances where I can’t use extension methods.