hougaard / ToolBox-Issues

Support Repository for Erik's ToolBox
1 stars 0 forks source link

Index out of bounds error on Option #3

Closed bdgjope closed 1 year ago

bdgjope commented 2 years ago

Hi Why am I getting an Index Out of Bounds error on this code: bild

If I comment out the call to InsertStoreInvWorksheet it works. So it has something to do with the Option. It does not matter if I call with a number or optionvalue. (I removed the code from the procedure to eliminate that the error came from somewhere in there).

By the way, does it work to set a field in a table that is a enum, if you set it as a number? Even if enum is not a supported type in the toolbox? Thanks in advance

hougaard commented 2 years ago

Are you on the latest version of the ToolBox, I fixed a few out-of-bounds issues lately?

bdgjope commented 2 years ago

According to my Environment I am up to date. Version 1.0.0.164.

hougaard commented 2 years ago

OK, I'll take a look, stay tuned.

hougaard commented 2 years ago

Bug identified, if you put the option field as the last parameter it might just work.

I'll submit an update to appsource real soon.

bdgjope commented 2 years ago

I can report that putting the option as the last parameter did not solve the issue.

hougaard commented 2 years ago

Try updating to the latest version from AppSource

bdgjope commented 2 years ago

This particular issue seems to be fixed in the latest version. I did however get an other error that I am not sure if it should work or not. I am trying to set an enum field. Maybe that is not supported? I checked and there is no Validation code on the field so the error is not due to that. I have double checked that I set the right numbers.

The strange thing here is that line 31 seems to work fine. So I tried to remove the line that caused the error. Then it seemingly ran to the end, before the error in the second image showed up.

bild

bild

hougaard commented 2 years ago

This is probably related, the other error was also a "ByReference" issue... I'll take a look later today.

hougaard commented 2 years ago

Hmm.. seems there was an enum vs option confusion thing going on (Enums are actually options behind the scenes), try updating (I just posted version 1.0.0.169) and try it again....

bdgjope commented 2 years ago

I tried the new version now and I am sorry to report that I am still getting the same error (well CacheNo:2 this time).

Anyway, I have published this code in an app for now, so there is no rush for me to get this error fixed

hougaard commented 2 years ago

Weird, I cannot reproduce it (with 1.0.0.169)

Can you boil the code down to a minimal example and post the code here?

bdgjope commented 2 years ago

This is a weird error. I removed as much code as I could and still get the error. This is what I ended up with. If I remove the variable from the procedure I don't get the error. I changed the variable to one in from Base instead of LS Central.

var OptType: Option Negative,Counting,LabelJnl,Positive; begin InsertStoreInvWorkSheet(OptType::LabelJnl); end;

procedure InsertStoreInvWorkSheet(OptType: Option Negative,Counting,LabelJnl,Positive) var SalesHeader: record "Sales Header"; begin end;

hougaard commented 2 years ago

Thanks, I know the issue now, will fix later today :)