IF(equivalence test) Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
doco
Posts: 28
Joined: 05 Sep 2021, 13:36
Location: CN94vx
Contact:

IF(equivalence test)

09 Oct 2021, 10:52

Attempting to learn user interaction with a ListBox.

The script has a Gui, Add, ListBox, vListViewFiles gGetListItem, PropSites | here | there | everywhere ; along with size location etc
When the user selects one of the four items in the listbox say 'PropSites', the code below is instanced:

Code: Select all


GetListItem:
		Gui, Submit, NoHide
		
		selection := ListViewFiles			; 	assignment operator
		
		MsgBox,,First, % selection            	;    	this message box shows PropSites has been selected
		
		if (selection = "PropSites")           	;	equivalence operator. nothing in this if struct is recognized - why? it is expected to show the msgbox,, n, % selection
			
			MsgBox,,Second,% selection    
			
		else if (selection = "everywhere")
			
			MsgBox,, Third, % selection
			
	;	end if
		
		MsgBox,,Fourth, % selection       	;    	this message box shows PropSites has been selected
	return 
Thanks in advance

doco
User avatar
Chunjee
Posts: 1417
Joined: 18 Apr 2014, 19:05
Contact:

Re: IF(equivalence test)  Topic is solved

09 Oct 2021, 12:32

I would recommend using brackets for readability but without the full script I can't see why it's not working. Your blank lines are different but it should work.

Code: Select all

selection := "PropSites"

if (selection = "PropSites") {
	MsgBox,,Second, % selection
} else if (selection = "everywhere") {
	
}
doco
Posts: 28
Joined: 05 Sep 2021, 13:36
Location: CN94vx
Contact:

Re: IF(equivalence test)

09 Oct 2021, 12:39

This is all of it...

Code: Select all

#SingleInstance, Force
;	-------------------------------------------------------------------------------------------------------------------
	Gui, New
	Gui, Font, s9 cBlue, Comic Sans MS
	Gui, Add, Picture, x0 y0 h500 w800, C:\workspace\images\slat12.png
	Gui, Font, s9 cBlue, Comic Sans MS
	Gui, Add, Picture, x0 y0 h500 w800, C:\workspace\images\slat12.png
;	-------------------------------------------------------------------------------------------------------------------
	Gui, Add, Text, x25 y300 h100 w250 +BackgroundTrans cWhite, This is my Chalk Board
;	-------------------------------------------------------------------------------------------------------------------
	Gui, Add, ListBox, x25 y280 h51 w251 r5 vListViewFiles gGetListItem +Border, PropSites | here | there | everywhere
	
	FileRead, Data1, C:\Users\coss-fin_services\Desktop\ahk\txt_data\prop_sites.txt
	LV_Table(Data1,",",1,"Oregon Repeaters")

	Gui, Show, x500 y500 h500 w800, Dashing

return

;	-------------------------------------------------------------------------------------------------------------------
;		FUNCTIONS
;	-------------------------------------------------------------------------------------------------------------------
LV_Table(Data_Source, delimiter = ",",UseHeader = 1,Title = "")						;	**** USER DEFINED FUNCTION ****
{ 
																					; 	default delimiter set to comma
		if FileExist(Data_Source) 													;	if file exists use it as source
			FileRead, Data_Source, %Data_Source% 									;	read in and store as variable
	;	end if		

																					;	parse the data in variable and store in object
	data_obj := StrSplit(Data_Source,"`n","`r") 									;	parse earch row and store in object
	rowHeader := StrReplace(data_obj.RemoveAt(1),Delimiter,"|",Numb_Columns) 		; 	Remove header from Object and convert to pipe delimited
		if (useHeader = 0)
		{
			loop, % Numb_Columns + 1
				RH .= "Col_" A_Index "|"
				rowHeader := RH
		;	Next Numb_Columns
		}
	;	end if

	dCols:= (Numb_Columns < 8) ? 400: ((Numb_Columns < 80) ? 650 : 1100) 			;	if cols <10 use 400; if cols <80 use 650 ; else use 1100
	dRows:= (data_obj.MaxIndex() > 27) ? 26 : data_obj.MaxIndex() 					;	if rows >27 use 26 else use # of rows

	Gui, Add, ListView, x25 y25 h250 w750 r%dRows% grid Border, % rowHeader ;%dCols%	;	set headers

		For Each, Row In data_obj 													;	add the data lines to the ListView
			LV_Add("", StrSplit(Row, Delimiter)*) 									;	LV_Add is a variadic function
	;	Next Row
}
return
;	-------------------------------------------------------------------------------------------------------------------
;		LABELS
;	-------------------------------------------------------------------------------------------------------------------
GetListItem:
		Gui, Submit, NoHide
		
		selection := ListViewFiles
		
		MsgBox,,First, % selection
		
		if (selection = "PropSites")
			
			MsgBox,,Second,% selection
			
		else if (selection = "Everywhere")
			
			MsgBox,, Third, % selection
			
	;	end if
		
		MsgBox,,Fourth, % selection
	return 



GuiClose:
	ExitApp

User avatar
Chunjee
Posts: 1417
Joined: 18 Apr 2014, 19:05
Contact:

Re: IF(equivalence test)

09 Oct 2021, 13:33

I get the messagebox.

Check that your script is saved with proper encoding
Image
doco
Posts: 28
Joined: 05 Sep 2021, 13:36
Location: CN94vx
Contact:

Re: IF(equivalence test)

09 Oct 2021, 14:01

I don't use Notepad ++. I am using Scite4autohotkey. I am assuming it knows ...
gregster
Posts: 8988
Joined: 30 Sep 2013, 06:48

Re: IF(equivalence test)

09 Oct 2021, 14:20

No, it doesn't. But there is a menu: File > Encoding > UTF-8 with BOM
doco
Posts: 28
Joined: 05 Sep 2021, 13:36
Location: CN94vx
Contact:

Re: IF(equivalence test)

09 Oct 2021, 15:14

image.png
image.png (12.61 KiB) Viewed 554 times
It is and was
just me
Posts: 9442
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: IF(equivalence test)

10 Oct 2021, 05:48

Code: Select all

Gui, Add, ListBox, vListViewFiles gGetListItem, PropSites | here | there | everywhere ; along with size location etc
creates the following entries (+ = space):

Code: Select all

PropSites+
+here+
+there+
+everywhere
To use if (selection = "PropSites") you have to remove the spaces from the list or from both ends of the selection.
hitman
Posts: 21
Joined: 10 Aug 2014, 06:47

Re: IF(equivalence test)

20 Oct 2021, 02:20

remove space

Code: Select all

selection:=trim(selection)

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 263 guests