IDE scripting question

  1. 6 weeks ago

    I am so new to xojo scripting I simply don't know and can't seem to find out; how do I reference a line at a time in a method with scripting language?

    Thanks guys, you all are awesome. I really appreciate your help!.

  2. Dave S

    Oct 31 San Diego, California USA

    @Paul A how do I reference a line at a time in a method

    just what do you mean....

    like

    GOTO 100
    GOSUB 250

    if so... you dont'.... and shouldn't....

  3. Kem T

    Oct 31 Pre-Release Testers, Xojo Pro, XDC Speakers New York
    dim code as string = Text
    dim codeLines() as string = code.Split( EndOfLine )
  4. I mean in the IDE script I am creating, If I assume that all the text,lines, etc in the module can be referenced by refering to the word Text, can I do this?
    dim x as integer
    x=Text.indexof("text")
    if x <> -1 then
    Text=Text.replace("text","Text")
    end if

    I want to be able to replace any matching string I give it with something else. The ReformatCode.xojo.script script works fine, but I want to create a simple script that only replaces certain instances of words with something else. If I am somehow referring to all lines of code in my method by using the word Text, then how can I specify the line I'm on?

    By the way the above code does not work it gives me Compiler error (87).

  5. Julian S

    Oct 31 Pre-Release Testers, Xojo Pro UK

    Might I suggest you grab this https://github.com/JulianSamphire/ReformatCode

    Either alter the source and add your personal additions to RC_ReplaceList() on line 25 or add the following string constant to your app:

    App.ReplaceWords

    Inside that string constant write

    Original,Replacement,Original2,Replacement2 etc

    and the alterations will be picked up automagically ;)

  6. Julian S

    Oct 31 Pre-Release Testers, Xojo Pro UK

    Oops, I forgot to answer your actual question. Unfortunately the reformat code script can't reference anything outside of the line or code block that it's currently working on. Also, there's currently a bug (Feedback Case #52343) so you can't even reference each line of a block that you're processing (i.e. from a pasted chunk of code).

  7. Thank you so much. I have been doing exactly that and it works beautifully, but I am trying to learn how to use this feature and it is pretty cryptic to me. I am attaching an image of the IDE. This is what thought you meant, but it doesn't work for me, or at least it doesn't change anything. What I am confused about now is if I create a new script with only the word ReplaceWords in it, am I doing it correctly? Will putting this constant in my app take care of it or do I have to mention it in my script?
    -image-

    As you can see I tried to insert the image but I don't know how to change the path to my Desktop. If it doesn't ask me to upload or drag and drop I don't know how to get it on the page. When I tried to drag it, it took over the entire window and wouldn't let me do anything else.

  8. Julian S

    Oct 31 Pre-Release Testers, Xojo Pro UK
    Edited 6 weeks ago

    Try dragging it into this page, then pasting the link in here:

    https://imgur.com/upload

    as long as there's nothing private in there of course.

  9. -image-

    Wow round about, but it works. Thanks. Now lets see if you can help after looking at this.

  10. Julian S

    Oct 31 Pre-Release Testers, Xojo Pro UK

    Here you go :)

    -image-

    Where you have written string in default value just type

    hello,world

    Then then you type hello it will replace it with world

  11. Julian S

    Oct 31 Pre-Release Testers, Xojo Pro UK

    If you want more just add them with comma separation like:

    hello,world,this,that,one,two

    Make sure there is always an even number of them. So the first is replaced with the second.

  12. Julian S

    Oct 31 Pre-Release Testers, Xojo Pro UK
    Edited 6 weeks ago

    Here's a link to my video about it :)

    https://youtu.be/IAVjh-xiO0w?t=561

  13. Thank you!

  14. Amazing! If I can accomplish this feat with only a constant, why would I want to or need to use a script?
    I'm sure there are plenty of reasons, I just can't see one in this case. At least it is there if I need it. Can I create constants named UpperCase, TitleCase, etc?

  15. Julian S

    Oct 31 Pre-Release Testers, Xojo Pro UK
    Edited 6 weeks ago

    Its only possible because Norman implemented it in the IDE so I could write that reformat code script :)

    Technically ReplaceWords will work for changing the case too, so you could enter:

    hello,HELLO

    and it would change hello to HELLO and similarly for case

    hello,HeLLo

    would change hello to HeLLo

    Or had you some other method/system in mind?

  16. Tim J

    Oct 31 Pre-Release Testers, Xojo Pro Dehydrating in AZ

    Without Julian's efforts here, you would be facing a IDE script exercise of near Herculean scope (okay, so maybe more Tom Sawyer-ish, but it would have still been a lot of work :P ).

  17. Paul A

    Oct 31 Answer

    Thanks guys, you all are awesome. I really appreciate your help!.

or Sign Up to reply!