With this method: sub getCodes(theChar as string) as string() Here’s an example of how to fill the fields in Xojo. The way we write the methods is just a standard way to write code. You cannot create methods without the gui. How can I make two methods out of the code you wrote, without removing the sub header footer, and without filling the return type and input type inside Xojo’s GUI fields? I mean I want to do it all by code like you pros. I have a ComboBox as I said, with items from A-Z, this method takes the ComboBox.listIndex and turns it into the corresponding character’s string. I think it’s a Xojo bug?īecause when I create a new method under the module or custom control, it shows up as “Untitled” in the autocomplete, but just when I change its name, or paste my code inside it, it disappears from autocomplete. I tried putting it into another module, changed the scope, putted it under a custom control, none of them worked. Then when I want to use them, I write “myModule.” and hit tab, StoreCodes, GetCodes, and CodeDict are all there in the autocomplete, but no trace of NumToChar is there. I made two methods out of the code you provided (and I’m very thankful for that!), using the GUI, and I also made another method named NumToChar, which I explain it below my question.How can I make two methods out of the code you wrote, without removing the sub header footer, and without filling the return type and input type inside Xojo’s GUI fields? I mean I want to do it all by code like you pros.'make sure the dictionary is initialized - could be placed in an “init” method Then upon encryption, every “A” in the text input is replaced randomly with one of the codes provided for “A”. Which are cut into pieces with “,” as the delimiter, each piece is trimmed of any whitespace, and put inside an array with the rest of pieces. “sdfgfdgd, sadadad, sdasdaf, asdada, fgdfgd, weqfvcvx, ytygbcv” Radium can you give an example of the sample data that you are needing to store? ![]() Return CodeDict.lookup(asc(theChar),array("")) 'Here we return an array with a single empty string element 'decide what value to return if the code is not found. Sub getCodes(theChar as string) as string() If CodeDict = nil then CodeDict = new dictionary 'make sure the dictionary is initialized - could be placed in an "init" method Sub StoreCodes(theChar as string,theCodes() as string) Oh, and since dictionary values are case insensitive, and you may want to store different codes for “A” and “a”, you might want to convert “theChar” parameter to its ascii code.Įxample (methods and property to be placed in a module) You can also change your storage methods anytime without affecting the rest of your code, as long as you keep both methods with the same parameters and return types. You could use a module for that, call it “data”, create a private property “CodeDict” dictionary, make two protected methods: storeCodes and getCodesīy using a module, you can use the methods anywhere as “Data. I would suggest encapsulating methods to store / extract data so you isolate your storage mechanism from the calling methods. ![]() When you lookup, you either need to cast the value, or predefine a variable or object of the right type before assigning the variant to it. ![]() Dictionaries store variants, so pretty much anything can go into a dictionary.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |