Associative Array for error codes...

would be nice to be able to do something like this:

{500:“internal Server Error”,501:“not implemented”}

just for example, so one could quickly build a table of codes to return value from.

Any suggestions, am I missing something here? I would hate to have to write a massive set of if/then’s to do something like this.

  • Joel

You can always do this:

codes = {}
codes.AddReplace("500","internal Server Error")
codes.AddReplace("501","not implemented")

then

error = SomeFunction() ' returns an Integer
?codes[error.toStr()]

Another option would be to build your table with a leading character:

codes = {x500:"internal Server Error",x501:"not implemented"}

then use:

?codes["x"+error.toStr()]

-JT

Not sure if this is what you were asking, but see this post for a list of error codes. This will be provided as a public AA in a future release.

–Mark

Thanks, I was really looking for the method as opposed to the codes, I used http codes as the example, but this is for a completely different set of codes.

-Joel