Should RawGet HasItem and HaveItem be interchangeable?

Report any Hollywood bugs here
Post Reply
Bugala
Posts: 1305
Joined: Sun Feb 14, 2010 7:11 pm

Should RawGet HasItem and HaveItem be interchangeable?

Post 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.
Flinx
Posts: 274
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Should RawGet HasItem and HaveItem be interchangeable?

Post 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.
Bugala
Posts: 1305
Joined: Sun Feb 14, 2010 7:11 pm

Re: Should RawGet HasItem and HaveItem be interchangeable?

Post 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.
Post Reply