Re: attaching multiple constants to 1 string
Re: attaching multiple constants to 1 string At post 13, read the language tutorial and check the examples.To insert a new line into a string, just write \r\n. So, for example:string multiline_string="This string\r\nspans\r\nmultiple lines.";Same to insert a quotation mark into a string, just do \".string observation="The word \"like\" is really overused.";HTH,Lukas URL: http://forum.audiogames.net/post/395921/#p395921 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: attaching multiple constants to 1 string
Re: attaching multiple constants to 1 string MacOS is just as weird -- it uses \r as its new line. Which is just odd URL: http://forum.audiogames.net/post/395911/#p395911 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: attaching multiple constants to 1 string
Re: attaching multiple constants to 1 string @13: It sounds like you haven't read about escape sequences. \n (new line), \r (carriage return, aka newline for windows because windows is weird like that), \" (a quote in a string literal), \', \\, \t (tab), etc.I don't think I understand what you were trying to do that wouldn't work? URL: http://forum.audiogames.net/post/395791/#p395791 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: attaching multiple constants to 1 string
Re: attaching multiple constants to 1 string @13, yeah, BGT doesn't have raw string literals, also known as here documents. Quite sad, that; here documents are incredibly useful. URL: http://forum.audiogames.net/post/395739/#p395739 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: attaching multiple constants to 1 string
Re: attaching multiple constants to 1 string Still not seeing the problem? Fundamentally, it's a set of rules for parsing strings. Implementing those rules might not be as easy as fizzbuzz, but I'm not sure what would make it so much harder as to require DLLs or built-in support. We're talking parsing rules, not hardware drivers or DSP. URL: http://forum.audiogames.net/post/395710/#p395710 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: attaching multiple constants to 1 string
Re: attaching multiple constants to 1 string @9, uh... because regular expressions are a lot more powerful than that? URL: http://forum.audiogames.net/post/395699/#p395699 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: attaching multiple constants to 1 string
Re: attaching multiple constants to 1 string ... Why? Why can't I just look up the most common rules and write an implementation like it's that expr assignment from CS102? I mean, aside from the fact that I'm not sure if I finished that assignment or not...? URL: http://forum.audiogames.net/post/395698/#p395698 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: attaching multiple constants to 1 string
Re: attaching multiple constants to 1 string If you were using regular expressions (and if the function was just called "match") you could just do:if (match(currentloc, "^house[0-9]$")) {//...}Believe me, your not going to get regular expressions in BGT any time soon. Unless you enjoy hacking together C++ DLLs, that is. Or getting PCRE/PCRE2 to work. Another reason to not use BGT... URL: http://forum.audiogames.net/post/395682/#p395682 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: attaching multiple constants to 1 string
Re: attaching multiple constants to 1 string Someone could probably hack together functions for working with regular expressions, if they haven't already. There'd need to be equivalents for equals, contains, replace, and split, and that would probably cover it. URL: http://forum.audiogames.net/post/395664/#p395664 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: attaching multiple constants to 1 string
Re: attaching multiple constants to 1 string I should have mentioned what language I am using, sorry for being so dumb. I am a bgt user. And @ post 5, yes, you interpreted my question correctly. BGT needs to be updated to support expressiions such as that one. URL: http://forum.audiogames.net/post/395648/#p395648 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: attaching multiple constants to 1 string
Re: attaching multiple constants to 1 string If you want the example you gave, to shorten if (cl == "house1" or cl == "house2") etc, you might tryif (string_left(cl, 5) == "house" and string_to_number(string_trim_left(cl, 5)) <= 5)IDR if python slices work with strings, but if so, it'd be something like if (cl[0:5] == "house" and int(cl[5:-1]) <= 5)Hopefully I didn't completely misunderstand what you were asking.[edit] Actually, if you can use regular expressions, then something like "house[1-5]" would do exactly what it sounds like you're asking for. IIRC, BGT does not support regular expressions, while Java and Python can (I do not remember how). [/edit] URL: http://forum.audiogames.net/post/395604/#p395604 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: attaching multiple constants to 1 string
Re: attaching multiple constants to 1 string If you want the example you gave, to shorten if (cl == "house1" or cl == "house2") etc, you might tryif (string_left(cl, 5) == "house" and string_to_number(string_trim_left(cl, 5)) <= 5)IDR if python slices work with strings, but if so, it'd be something like if (cl[0:5] == "house" and int(cl[5:-1]) <= 5)Hopefully I didn't completely misunderstand what you were asking. URL: http://forum.audiogames.net/post/395604/#p395604 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: attaching multiple constants to 1 string
Re: attaching multiple constants to 1 string It depends on how your structuring your data, using Classes with dictionaries or multi-dimensional lists can be a good way to keep track of location data or doing checks and iteration. For example you could put a house class in a dictionary and do a quick comparison like so:class house(object): def update(self): print('house things') block = {'house1':house(),'house2':house(),'house3':house(),'house4':house(),'house5':house()} block[currentloc].update()Or with lists with currentloc being an integer:class house(object): def update(self): print('house things') block = [house(),house(),house(),house(),house()] block[currentloc].update() URL: http://forum.audiogames.net/post/395601/#p395601 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: attaching multiple constants to 1 string
Re: attaching multiple constants to 1 string Maybe you can make an array and you can loop through the items. If array.find or something. You never said what language you were using so... URL: http://forum.audiogames.net/post/395578/#p395578 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
Re: attaching multiple constants to 1 string
Re: attaching multiple constants to 1 string sorry for posting twice. I just realized this may not be possible since you have to state whether the condition is and, or or. But maybe there is a way to shorten it even if the method I was thinking of doesn't work. Let me know if you have solved this issue please. URL: http://forum.audiogames.net/post/395576/#p395576 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
attaching multiple constants to 1 string
attaching multiple constants to 1 string This issue has pissed me off for many years now. I have a line of code that I don't want very long. To shorten it, I want to be able to write the string, then the starting and ending number. For example, house 1 through 5. Instead of writing if(currentloc=="house1" or currentloc=="house2" or currentloc=="house3", ect, I want to be able to write if (currentloc=="house"1,5 to shorten it. I've already figured out making a string variable and adding it to the end, if (currentloc=="house"+string, helps, but what do I write in that string variable to make it recognize numbers 1 through 5? Thanks URL: http://forum.audiogames.net/post/395574/#p395574 -- Audiogames-reflector mailing list Audiogames-reflector@sabahattin-gucukoglu.com https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector