Jump to content

How to group codes together


Brendzt
 Share

Recommended Posts

I grabbed an example, It has all these functions to just to use the Random function. Is there away to put this into a group so I can collapse/hide it so I don't have to scroll so far while typing more code?

HotKeySet("{F1}", "RunFunc")

While (1)
    Sleep(100)
WEnd

Func RunFunc()
    Local $aFuncs[3] = [camera1, camera2, camera3]
    $aFuncs[Random(0, 2, 1)]()
EndFunc   ;==>RunFunc


Func camera1()
    MsgBox(0, 0, "camera1")
EndFunc   ;==>camera1

Func camera2()
    MsgBox(0, 0, "camera2")
EndFunc   ;==>camera2

Func camera3()
    MsgBox(0, 0, "camera3")
EndFunc   ;==>camera3

Because I do see an option just to collapse each Function, but I want to mass collapse this whole section 

Edited by Brendzt
Link to comment
Share on other sites

  • Moderators

Brendzt,

Use the SciTE #region...#endregion directives - details are in the SciTE help file.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

HotKeySet("{F1}", "RunFunc")
#Region runfunc
While (1)
    Sleep(100)
WEnd

Func RunFunc()
    Local $aFuncs[3] = [camera1, camera2, camera3]
    $aFuncs[Random(0, 2, 1)]()
EndFunc   ;==>RunFunc
#endregion
#Region camera1
Func camera1()
    MsgBox(0, 0, "camera1")
EndFunc   ;==>camera1
#endregion
#Region camera2
Func camera2()
    MsgBox(0, 0, "camera2")
EndFunc   ;==>camera2
#endregion
#Region camera3
Func camera3()
    MsgBox(0, 0, "camera3")
EndFunc   ;==>camera3
#endregion

 

Link to comment
Share on other sites

  • Moderators

Atrax27,

Functions are automatically collapsable, so a #region...#endregion directive serves no useful purpose placed around an Func...EndFunc pairing.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

@Melba23 I had another question,  I saw you on the example post that I grabbed. Just to clarify in the "

 $aFuncs[Random(0, 2, 1)]()

if I changed that to only have (0,2) or if I had a total of calling 5 functions and I wanted all of them called randomly I would changed that to (0,5)? 

Edited by Brendzt
Link to comment
Share on other sites

Hey,

If you read the function page it would help a lot.

Random ( [Min = 0 [, Max = 1 [, Flag = 0]]] )

Parameters

Min [optional] The smallest number to be generated. The default is 0.
Max [optional] The largest number to be generated. The default is 1.
Flag [optional] If this is set to 1 then an integer result will be returned. Default is a floating point number.

so in order to get a random integer, in range 1-5 you would need to use

random(1,5,1)

Edited by GokAy
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...