TheMightySwe Active Member Licensed User Longtime User Mar 16, 2015 #1 Is there any way to step through a "Type" like the one below in some kind of loop? Code: Type SQLTypes (BlobType As Int, DateTimeType As Int, StringType As Int, DoubleType As Int, IntType As Int, BooleanType As Int)
Is there any way to step through a "Type" like the one below in some kind of loop? Code: Type SQLTypes (BlobType As Int, DateTimeType As Int, StringType As Int, DoubleType As Int, IntType As Int, BooleanType As Int)
Erel B4X founder Staff member Licensed User Longtime User Mar 17, 2015 #2 Do you want to go over all the fields? Create a sub that receives this type and returns a Map with the fields names as keys and the values. Upvote 0
Do you want to go over all the fields? Create a sub that receives this type and returns a Map with the fields names as keys and the values.
TheMightySwe Active Member Licensed User Longtime User Mar 17, 2015 #3 So how do I do that convertion from the type to the map? Upvote 0
T Troberg Well-Known Member Licensed User Longtime User Mar 17, 2015 #4 You'll have to do it manually, field by field. Bara kavla upp ärmarna, ladda med kaffe och köra igång... Upvote 0
You'll have to do it manually, field by field. Bara kavla upp ärmarna, ladda med kaffe och köra igång...
Erel B4X founder Staff member Licensed User Longtime User Mar 18, 2015 #5 Code: Sub SQLTypesToMap (t As SQLTypes) As Map Return CreateMap("Blobtype": t.Blobtype, "DateTimeType": t.DateTimeType, ...) End Sub Upvote 0
Code: Sub SQLTypesToMap (t As SQLTypes) As Map Return CreateMap("Blobtype": t.Blobtype, "DateTimeType": t.DateTimeType, ...) End Sub
TheMightySwe Active Member Licensed User Longtime User Mar 18, 2015 #6 OK, oh my! That might work, but with a huge problem. My Type has almost a thousand Integers and changes alot when new functions are added. Is there any way to step through it to get the Variable names? If not, i just do it the hard way. // TMS Upvote 0
OK, oh my! That might work, but with a huge problem. My Type has almost a thousand Integers and changes alot when new functions are added. Is there any way to step through it to get the Variable names? If not, i just do it the hard way. // TMS
Erel B4X founder Staff member Licensed User Longtime User Mar 18, 2015 #7 Why do you need to go over all the fields? If you want to serialize the type instances then there are simpler ways to do it. Upvote 0
Why do you need to go over all the fields? If you want to serialize the type instances then there are simpler ways to do it.
TheMightySwe Active Member Licensed User Longtime User Mar 18, 2015 #8 I want to use the Names from the type instances for a map that saves if a user has or hasn't access to the function that corresponds with the type instance. Upvote 0
I want to use the Names from the type instances for a map that saves if a user has or hasn't access to the function that corresponds with the type instance.
T Troberg Well-Known Member Licensed User Longtime User Mar 19, 2015 #9 Maybe you should take a step back and reconsider using a type and think about using some other construct instead? Class, map, array, list, database are all viable alternatives, depending a bit on your specific needs. Upvote 0
Maybe you should take a step back and reconsider using a type and think about using some other construct instead? Class, map, array, list, database are all viable alternatives, depending a bit on your specific needs.
Erel B4X founder Staff member Licensed User Longtime User Mar 19, 2015 #10 TheMightySwe said: I want to use the Names from the type instances for a map that saves if a user has or hasn't access to the function that corresponds with the type instance. Click to expand... Use KeyValueStore (or RandomAccessFile.WriteB4XObject). It allows you to save a type instance or any collection that holds other types in a single line of code. Upvote 0
TheMightySwe said: I want to use the Names from the type instances for a map that saves if a user has or hasn't access to the function that corresponds with the type instance. Click to expand... Use KeyValueStore (or RandomAccessFile.WriteB4XObject). It allows you to save a type instance or any collection that holds other types in a single line of code.
TheMightySwe Active Member Licensed User Longtime User Mar 19, 2015 #11 The thing is i can't change this because its embedded in thousands of places in a huge project, if it's not possible to get the variables names out, I will fix another solution ofcourse. But it does not hurt to ask. Upvote 0
The thing is i can't change this because its embedded in thousands of places in a huge project, if it's not possible to get the variables names out, I will fix another solution ofcourse. But it does not hurt to ask.
T Troberg Well-Known Member Licensed User Longtime User Mar 19, 2015 #12 I don't know the project, but, in my experience, don't underestimate the power of search and replace, and simple find and manual correct. I'd make a copy of the project, and then start doing the change, just to get a feel for how big it really is. Usually, when I fear a big rewrite, it's much less work than I thought. Upvote 0
I don't know the project, but, in my experience, don't underestimate the power of search and replace, and simple find and manual correct. I'd make a copy of the project, and then start doing the change, just to get a feel for how big it really is. Usually, when I fear a big rewrite, it's much less work than I thought.