How to complete a task list?

Just starting out? Need help? Post your questions and find answers here.
AZJIO
Addict
Addict
Posts: 1355
Joined: Sun May 14, 2017 1:48 am

How to complete a task list?

Post by AZJIO »

There is a program called XnConvert that can collect a list of tasks to automate and execute it. How to do something like this?
I want to add a hotkey and bind a task list to it. I can use bit flags 1, 2, 4, 8, 16 to associate each task with it, but I don't have the priority of the task being executed. I can associate each task with a number 1, 2, 3, 4 and add the order in which the task is executed:
1.2
2.1
3.4
4.3
But at the same time I will have to make a complex ini file. Whereas before I could simply specify a number using bit flags, because of priority I need to specify the task number in the chain. Maybe I should use a double word to record the task number and position on the list.
If I use a function pointer, then functions should not have parameters, that is, I need to have a parameter structure before calling the function.

I want to make the user order tasks from the list and bind a hotkey to them.

Code: Select all

;- TOP
EnableExplicit
Define NbTask, evg, iData
NbTask = 0

;- ╔═ GUI ═╗
If OpenWindow(0, 0, 0, 340, 400, "Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	TreeGadget(0, 10, 10, 180, 340)
	ButtonGadget(1, 200, 10, 120, 27, "Select a word")
	ButtonGadget(2, 200, 40, 120, 27, "Select line")
	ButtonGadget(3, 200, 70, 120, 27, "Lower case")
	ButtonGadget(4, 200, 100, 120, 27, "Upper case")
	ButtonGadget(5, 200, 130, 120, 27, "Sentence case")
	ButtonGadget(6, 200, 160, 120, 27, "Capitalization")
	ButtonGadget(7, 200, 190, 120, 27, "Inverting")
	ButtonGadget(8, 200, 220, 120, 27, "Transliteration")
	
	ButtonGadget(9, 10, 350, 120, 27, "Add a task")

;-┌──Loop──┐
	Repeat
		Select WaitWindowEvent()
;-…… Gadget Events ……
			Case #PB_Event_Gadget
				evg = EventGadget()
				Select evg
					Case 1 To 8
						If Not NbTask
							MessageRequester("","First add a task")
							Continue
						EndIf
						AddGadgetItem(0, -1, GetGadgetText(evg), 0, 1)
						iData = GetGadgetItemData(0 , 1)
						SetGadgetItemData(0, 1 , iData | Int(Pow(2.0, evg)))
					Case 9
						NbTask + 1
						AddGadgetItem(0, -1, "New task" + Str(NbTask), 0, 0)
					Case 0
						If EventType()  = #PB_EventType_LeftClick
							Debug GetGadgetItemData(0 , 1)
						EndIf
				EndSelect
			Case #PB_Event_CloseWindow
				CloseWindow(0)
				End
		EndSelect
	ForEver
EndIf
Here I tried to perform tasks according to the list

Code: Select all

EnableExplicit
Define evg, evprm, thread

Structure Task
	id.i
	List TaskList.i()
EndStructure

Procedure Uppercase(*funk.Task)
	Debug "Uppercase"
	Debug *funk\id
EndProcedure

Procedure Inverting(*funk.Task)
	Debug "Inverting"
	Debug *funk\id
EndProcedure

Procedure SelectWord(*funk.Task)
	Debug "SelectWord"
	Debug *funk\id
EndProcedure

Global NewList hotkey.Task()
AddElement(hotkey())
hotkey()\id = 1001
AddElement(hotkey()\TaskList())
hotkey()\TaskList() = @SelectWord()
AddElement(hotkey()\TaskList())
hotkey()\TaskList() = @Uppercase()
AddElement(hotkey()\TaskList())
hotkey()\TaskList() = @Inverting()


If OpenWindow(0, 0, 0, 340, 400, "Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	ButtonGadget(1, 10, 10, 120, 27, "forced")
	
	Repeat
		Select WaitWindowEvent()
				;-…… Gadget Events ……
			Case #PB_Event_Gadget
				evg = EventGadget()
				Select evg
					Case 1
						; Case #WM_HOTKEY
						; evprm = EventwParam()
						evprm = 1001
						ForEach hotkey()
							If evprm = hotkey()\id
								ForEach hotkey()\TaskList()
; 									Debug hotkey()\TaskList()
									thread = CreateThread(hotkey()\TaskList(), hotkey())
									If thread
										WaitThread(thread)
										Debug "done"
									EndIf

								Next
							EndIf
						Next
				EndSelect
			Case #PB_Event_CloseWindow
				CloseWindow(0)
				End
		EndSelect
	ForEver
EndIf
User avatar
idle
Always Here
Always Here
Posts: 5089
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: How to complete a task list?

Post by idle »

using more bits, sounds like the right idea.
AZJIO
Addict
Addict
Posts: 1355
Joined: Sun May 14, 2017 1:48 am

Re: How to complete a task list?

Post by AZJIO »

TextCorrectionPB
Download upload, yandex

Tasks are saved like this

Code: Select all

[tasks]
732=0.4.12
703=0.6.12
731=0.8.12
733=0.7.12
592=0.11.12
587=0.10.12
734=2.5.12
To quickly get the result, run the program, place the cursor at the end of the word and press Ctrl+[ you will get text with capital letters. I hope now you will be interested in trying the remaining features of the program.
The program will give the greatest opportunities to those whose native language consists of non-Latin letters. It corrects the text if your native language is used, but the keyboard layout turns out to be in English and vice versa. You just need to press the hotkey Ctrl+\. But it won’t work right away, since the program contains language code 419 (Ru). You need to change this number. Of course I can add it to the settings, maybe I'll do that later. You also need to change the letters in the variables Ru$, RuT$, Translit1$, Translit2$, or change this in the text-correction.ini file

There are also numbers 67699721 and 68748313. MakeLong(1033, 1033) and MakeLong(1049, 1049)
This code won't work either.

Code: Select all

*c\c <= 'А') Or *c\c = 'Я'
*c\c - 32
Previously, I used the universal method of iterating through letters from an array made from the Ru$ variable, but I decided to speed it up by specifying a range, and the universality was lost

screenshot
https://www.purebasic.fr/english/viewto ... 93#p564693
User avatar
idle
Always Here
Always Here
Posts: 5089
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: How to complete a task list?

Post by idle »

maybe you could do it something like this

Code: Select all

Structure int64  
  StructureUnion
    a.a[8]
    u.u[4]
    l.l[2]
    q.q
  EndStructureUnion
EndStructure   

Dim tasks.int64(10) 

For a = 0 To 9 
  tasks(a)\a[0] = a 
  tasks(a)\a[1] = Random(255) ;priority 
Next 

SortStructuredArray(tasks(),#PB_Sort_Descending,OffsetOf(int64\q),#PB_Quad) 

For a = 0 To 9 
  Debug "task number" + Str(tasks(a)\a[0]) 
  Debug "priority " + Str(tasks(a)\a[1]) 
Next   

Post Reply