April 20, 2024, 02:57:09 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Copying code to the clipboard

Started by Andy, March 26, 2016, 06:59:11 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

March 26, 2016, 06:59:11 AM Last Edit: March 26, 2016, 07:06:14 AM by Andy
This is the beggings of a handy little utility (at least for me).

It allows you to copy a sub routing in an iwb / inc file to the clipboard / file.

This is still in It's infancy - will work on this more over the next day or two.

How to use:

1. Compile (of course).
2. Go to one of your iwb source files.
3. Copy the name of the sub you want to copy.

Example - I have an iwb file called test.iwb
In there is a sub called MySub....

SUB MySub(something),INT

Copy and paste the "MySub" into the edit box.

4. Make sure SUB radio button is selected.
5. Click "Select File" and browse to your iwb file that contains that sub routine (in this case test.iwb).
6. Make sure "Send to clipboard" is selected.
7. Click "Proceed".

When the window caption says "Completed" - It's done.

You should now be able to open a new empty iwb file and paste the whole sub routine in.

There are several things I need to modify / amend, but you can see it has great potential (at least for me) who writes some very large sub routines.

Thanks,
Andy.
:)

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

aurelCB

QuoteCompiling...
ToClipboard.eba
File: D:\EBasicprogs\ToClipboard.eba (178) undefined variable - break
Error(s) in compiling D:\EBasicprogs\ToClipboard.eba

sorry Andy i have tried your program  and found above
/ yes i use EB /
but what is variable break   ::)

aurelCB

ok i comment break
is that your program now?

Andy

Hi aurel,

From the IWB help file:

"BREAK allows an early exit from the nearest FOR/NEXT, DO/UNTIL, or WHILE/ENDWHILE loop before the loop has finished all of the iterations."

If you are using EB, you could replace the BREAK command with a GOTO command.

The BREAK line is simply jumping out of the WHILE / ENDWHILE loop.

So instead of BREAK you could try replacing it with "GOTO jumpout"

Where jumpout is a label AFTER the ENDWHILE line.

      'break (remove / comment out)
      goto jumpout
else
     setcaption win," File could not be opened."
endif

endwhile

LABEL jumpout
CLOSEFILE myfile
CLOSEFILE myfile3

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

March 27, 2016, 05:12:55 AM #4 Last Edit: March 27, 2016, 05:23:42 AM by Andy
Hi,

I've now added in some more features.

You can now copy / paste the following blocks of code:

   Sub / Endsub
   For / Next
   If / Endif
   While / Endwhile

The program can work with nested blocks too

Example:

     if radio2state = 1
                if instr(Operator,"for ")
                   Operator = mid$(Operator,5,len(Operator))

                   if x = y
                      print a
                      print b
                   endif

                endif

               Find$ = "for " + Operator
               KeyWord = "next " + mid$(Operator,1,1)
     endif

In the statement edit box you can simply copy / paste the line you want

Example:
for x = 1 to 500

The correct radiobox will be selected (in this case "FOR").

So, as stated before:

1. Copy the statement into the edit box
2. Make sure the correct radiobutton is selected for that type of statement (sub, for, if, while)
3. Select the IWB / EBA / INC file that contains the statement
4. Click proceed.

When the edit box becomes blank and the window caption says "Completed" you can go to a new empty IWB / EBA file and copy the code in.

Attached is the updated program and a 1test.iwb file (which is nonsense - don't compile that one) for testing purposes.

Thanks,
Andy.



Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

March 28, 2016, 07:01:27 AM #5 Last Edit: March 28, 2016, 01:21:25 PM by Andy
This I think is the final version for now.

I've added in a search for DO / UNTIL (where you have to put the UNTIL statement in)

Example:

until x > y   (in the statement edit box).


Also, I've added the WHILE / WEND search option.

This code is certainly helping me, hope at some point it helps you too!

Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.