Paste code from Forum ? Xojo

I’m posting this in “Getting Started” because it seems like a fairly basic question that I’m just missing the answer to.

Say I’ve found a forum post with a few methods in it that I’d like to paste into Xojo:

Function abc(x as integer, y as double) as string
' code
End Function

Private Function def (i as string, a as string, byref b as boolean) as integer
' code
End Function

How do I now paste this code into the Xojo IDE without having to retype all of the definitions then pasting the code into the body of the method?

as far as I know… you can’t

what I usually do. is paste the whole thing into XOJO
delete the END FUNCTION line
copy the signature (between the () ) and paste it into the inspector
and type in the rest

and its not just coming from the forum… its from any source that you “cut” from where the code is like this

Copy them individually and select the Window , Module or class where want it, and paste. The method will be added to to … at least on a Mac.

  • Karen

[quote=254238:@Dave S]
what I usually do. is paste the whole thing into XOJO
delete the END FUNCTION line
copy the signature (between the () ) and paste it into the inspector
and type in the rest[/quote]

Thanks. That’s pretty awkward to be honest. You can’t paste multiple methods simultaneously? Maybe into a text file and then import it into Xojo?

Thanks, I’ve tried this (on a Mac) and the method isn’t created in the window I had selected. Xojo seems to take the paste with no effect.

Strange because I just did it. Maybe you are not selecting selecting the the the right stuff?

BTW I paste the method using a contextual menu (right click)… Try that.

  • Karen

[quote=254243:@Karen Atkocius]Copy them individually and select the Window , Module or class where want it, and paste. The method will be added to to … at least on a Mac.

  • Karen[/quote]
    Works fine on Windows too. Just copy the function declaration through the end and it drops right in. My experience is that you need to paste it into the code window.

Ah, okay, I got it to work by right-clicking on the Window in the Contents and choosing Paste. But it only pastes the first function on the clipboard. If there are many functions in a row, only the first is added.

Thanks for the help everyone.

It worked sometimes ago on OS X, then I needed to press the Option key while selecting the Paste MenuItem or drop onto what was the Navigation pane, and now it does not works at all like Dave said earlier.

Code selection in the Code Editor and activating the ContextualMenu Add As Method (or so) does not wk-orks too (as I expect it to do). I think the code is pasted in the declaration field (I do not recall).

Becasue nobody complain, I was thinking that I was suffering to some disease… ;-:slight_smile:

Pasting into the navigation pane has never worked for me. If you paste the code into the code editor it works.

Try this…

using your functions above…

Function abc(x as integer, y as double) as string
’ code
End Function

Private Function def (i as string, a as string, byref b as boolean) as integer
’ code
End Function

Select and copy the first one like this,

Function abc(x as integer, y as double) as string
’ code
End Function

Now highlight the window, e.g… Window1, you would like to use that function and click paste.

For me the function as you would like it to be is inserted… nothing to edit.

Now, try it with the the secon one like this,
Private Function def (i as string, a as string, byref b as boolean) as integer
’ code
End Function

again, for me the function as you would like it to be is inserted… nothing to edit.

Lennox

In xojo, you are certainly correct, I will not discuss. BUT, in Real Studio (or/and ? in REALbasic) this worked fine.

So, this is why it does not worked ! I was asking myself what I’ve done wrong ! Thank you for the information.

I really need another cup of coffee to awaken my brain to more than 50% (50% is not enough !)

Although pasting copied text methods only works for one method at at a time, pasting a method into a navigator object and having the method created works for me in Xojo on a Mac.

It would be nice if it did some simple parsing (Looking for End Method or End Function) so you COULD paste multiple methods, but not a big deal for me.

  • Karen

This can be of interest too : https://forum.xojo.com/30955-copy-and-paste-a-class-definition-from-text

Same here on that subject.

BTW: do you know alt-shift-click in an object in the navigation pane ?

In the old time, this also worked for click(s) in the Code Editor…

Page Not Found

For this Link to work, you need access to the Pro Forum.

Why in the world would that thread starter (whoever they may be) think that should be a “Pro” only topic? That type of thing is why I did not think a Pro only forum was a good idea.

BTW In general (at least in the forum for the rest of us) I don’t find the discussions to be as interesting or as in depth as they were on the NUG… I learned a lot on the NUG. BTW I felt the same way about the old REAL Forum.

Now I don’t know if that is because of the existence of the Pro forum or some other reason.

  • Karen

Last time I heard about a Pro forum that was Xojo (Real ? Geoff ?) who said they do not like to split (segment) the forum.

Now I understand there is an invisible for the rest of us Pro Forum ? Nice. :frowning:

It’s OK if it helps them make more money! :wink:

BTW I just realized my last post was not clear. In general I did not find the discussions as in depth on the old REAL forum as on the NUG either.

  • Karen

Karen, I am sorry for having pointed to a Pro forum discussion. Not sure why a hobbyist should criticize one of the tools professionals use to communicate, though. Especially when most of them go out of their way to share their knowledge and assist all in the general forum.

Let me echo the solution offered by Norman, to a question that was very similar :

Q : [quote]I have 100’s of classes that i need to get into Xojo, currently they are in a different language which i can get them from as its a text file.

is there a way to paste that text into Xojo and have it create the class object?[/quote]

I suggested modifying an XML project, but

A : [quote]XML really sucks for this

vcp is much simpler
[/quote]

#tag Class Class Class1 property key01 As Integer End Class #tag EndClass