Page 1 of 1

Should RawGet HasItem and HaveItem be interchangeable?

Posted: Mon Jan 20, 2025 1:26 pm
by Bugala
I made this short code as a reply on another topic here:

Code: Select all

t_HostSystems = { ["AmigaOS3"] = {SystemType = "AOS", SystemSpecific = "AOS3"},
		  ["AmigaOS4"] = {SystemType = "AOS", SystemSpecific = "AOS4"}
		}
		
t_HostSystems = {}

Function AddHostSystem(versionname, SystemType, SystemSpecific)
	t_HostSystems[versionname] = {SystemType = SystemType, SystemSpecific = SystemSpecific}
EndFunction

AddHostSystem("AmigaOS3", "AOS", "AOS3")
AddHostSystem("AmigaOS4", "AOS", "AOS4")
AddHostSystem("AROS", "AOS", "AROS")
AddHostSystem("MorphOS", "AOS", "MorphOS")
AddHostSystem("MacOS", "MacOS", "MacOS")
AddHostSystem("Win32", "W", "Win32")

Local Version = GetVersion().Platform
Local SystemType = "Unknown"
Local SystemSpecific = "Unknown"


If RawGet(t_HostSystems, Version)
	SystemType = t_Hostsystems[Version].SystemType
	SystemSpecific = t_HostSystems[Version].SystemSpecific
EndIf


DebugPrint("Detected system type:", SystemType)
DebugPrint("Detected specific system:", SystemSpecific)
	
Strange thing was that instead of using RAWGET, I first used HASITEM, and tried HAVEITEM as well, but they failed to work. Only RawGet works.

Hollywood manual gives me an impression that HasItem and HaveItem can both be used instead of RawGet, but is this so or not? For at least in this case they didn't work interchangeably, but using HasItem or HaveItem makes this code not work properly.

Hollywood 10, Windows 11.

Re: Should RawGet HasItem and HaveItem be interchangeable?

Posted: Mon Jan 20, 2025 2:21 pm
by Flinx
From the manual:
HaveItem/HasItem
Note that if you pass a string in the key parameter, it will be converted to lower case automatically. If you don't want that, use RawGet() instead.

Re: Should RawGet HasItem and HaveItem be interchangeable?

Posted: Mon Jan 20, 2025 3:31 pm
by Bugala
Seems I read the manual very badly, especially since I was even bit of recalling something like that and still missed it when read.