Logman Posted December 30, 2006 Share Posted December 30, 2006 Hi, how including file defined in a variable? This is't working: #include <GUIConstants.au3> ; select language ... $lang = "en" ... $langfile = "lang_" & $lang & ".au3" #include $lngfile ; <- this didn't work ... ... ... Sorry for my bad english Link to comment Share on other sites More sharing options...
xcal Posted December 30, 2006 Share Posted December 30, 2006 (edited) You can do it like this: $lang = InputBox('', '') If $lang = 'en' Then #include <lang_en.au3> ElseIf $lang = 'other' Then #include <lang_other.au3> EndIf ;etc edit - btw, this is from the helpfile regarding the #include filename: "The filename of the current script to include. Path is optional. This must be a string--it cannot be a variable." Edited December 30, 2006 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Logman Posted December 30, 2006 Author Share Posted December 30, 2006 ... this must be a string--it cannot be a variable."Thanks, xcal, for fast reply! I'll observe the terms in help file... Link to comment Share on other sites More sharing options...
Valik Posted January 1, 2007 Share Posted January 1, 2007 You can do it like this: $lang = InputBox('', '') If $lang = 'en' Then #include <lang_en.au3> ElseIf $lang = 'other' Then #include <lang_other.au3> EndIf ;etc edit - btw, this is from the helpfile regarding the #include filename: "The filename of the current script to include. Path is optional. This must be a string--it cannot be a variable."Did you put any more thought into this answer than the OP did the question? Do you expect that to work how it's written when compiled and run on a different computer? Link to comment Share on other sites More sharing options...
xcal Posted January 1, 2007 Share Posted January 1, 2007 (edited) Did you put any more thought into this answer than the OP did the question? Do you expect that to work how it's written when compiled and run on a different computer?I was only answering the question - nothing more. I know about as much of what he's actually doing as you do. That would be nothing. Maybe it'll work for him. Do you know if he'll be running it compiled? Or even on other computers? It's implied by the multi-language setup, but you don't really know. Maybe it won't work and he'll have learned something himself in the process? Who knows? We don't. But you want to see his 4 line non-functioning example to fruition?So, how much thought did you put in to your post? editAnd you know what... Out of my 365 posts I've only asked maybe 5 questions. I'm not the best coder/scripter, but I spend a lot of my free time trying to help people or give them a push in the right direction because I want to support Autoit in the small way I can. So don't go directing your shitty attitude towards people who don't deserve it. Edited January 1, 2007 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Valik Posted January 1, 2007 Share Posted January 1, 2007 Answering the question would be something like, "What you're trying to do makes no sense and is not possible." What you did was write some code that makes no sense and give false hope to an already mis-guided user. Link to comment Share on other sites More sharing options...
xcal Posted January 1, 2007 Share Posted January 1, 2007 (edited) Answering the question would be something like, "What you're trying to do makes no sense and is not possible."No, that's speculation and commentary, and it is actually possible. I was just answering the question. If you want to do some hand-holding, direct it towards him - I wasn't asking for it. Edited January 1, 2007 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Zach Posted January 1, 2007 Share Posted January 1, 2007 I assume you can use the #include in an included file right? .. which means - you could dynamically include includes by making the initial include file on the fly which includes the include files actually wanted. Link to comment Share on other sites More sharing options...
Valik Posted January 1, 2007 Share Posted January 1, 2007 No, that's speculation and commentary, and it is actually possible. I was just answering the question. If you want to do some hand-holding, direct it towards him - I wasn't asking for it. Oh, it's possible? Well, what do I know? It's not like I wrote the code that handles #include or anything. Link to comment Share on other sites More sharing options...
xcal Posted January 1, 2007 Share Posted January 1, 2007 (edited) I don't post stuff without trying it first. It works in uncompiled form as long as the files exist.I wrote the code that...Why do I get the feeling that's tattooed backwards on your forehead so you can see it every time you come across a mirror...edit - unclosed tag Edited January 1, 2007 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Valik Posted January 1, 2007 Share Posted January 1, 2007 (edited) Stop being an idiot for a bit, xcal. All files are included. Period. No run-time If...Then logic is going to conditionally include - or not - a file. If you happen to be including a file that is "pure code", then it will kind-of work. But if there is a single function declaration, the script won't even run. But the file will be included, regardless. It may just be that the code isn't reached.What the OP asked for and the code you showed is stupid, ill-thought-out, not-possible and the wrong way to approach the problem. Feel free to continue to make yourself look like a jackass if you wish. Arguing with the person who knows the feature best and knows it's capabilities and limitations isn't exactly the smartest thing you can do. Snide comments about my ego aside, quite simply, I wrote the feature, I know how it works, it's not rocket science. It doesn't work like you want to think it does and trying to tell me otherwise is just plain foolish.Edit: Minor correction. Edited January 1, 2007 by Valik Link to comment Share on other sites More sharing options...
xcal Posted January 1, 2007 Share Posted January 1, 2007 So even you say it kind of works with limitations. So, will those limitations affect him? Did they affect my test? How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
Valik Posted January 1, 2007 Share Posted January 1, 2007 Well, I see you're an idiot. I didn't think you were, but it seems that you are. You're so worried about defending your shitty code that you won't acknowledge that it's shitty code that only an idiot would write. Oh well. Looks like we have another person to add to the list of people who are too right to be wrong. Link to comment Share on other sites More sharing options...
hearurscream Posted January 1, 2007 Share Posted January 1, 2007 So even you say it kind of works with limitations.So, will those limitations affect him? Did they affect my test?What Valik is trying to get at, is that you cannot determine whether or not you include a file in an If...Then statement.The files will be included whether the If statement calls for them or not.The simplest solution is to include all the files and, depending on user input, use the appropriate functions. Infinity is a floorless room without walls or ceiling.Anyone who cannot cope with mathematics is not fully human. At best he is a tolerable subhuman who has learned to wear shoes, bathe, and not make messes in the house. Link to comment Share on other sites More sharing options...
xcal Posted January 1, 2007 Share Posted January 1, 2007 And you just ignored what I said, too.Your post #11 was all about whether it works or not. That's what I was replying to. You are following the progression of the discussion, right?If someone was creating a language file, it's just going to be vars and strings. What I posted does work for uncompiled scripts. You said "No run-time If...Then logic is going to conditionally include - or not - a file." You are wrong.You're also assuming that I think it's good code? You're assuming way too much. How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
xcal Posted January 1, 2007 Share Posted January 1, 2007 (edited) What Valik is trying to get at, is that you cannot determine whether or not you include a file in an If...Then statement.The files will be included whether the If statement calls for them or not.The simplest solution is to include all the files and, depending on user input, use the appropriate functions.I know what valik is getting it.The files are not included if the 'If' statement doesn't call for them.Yes, I agree, that is the best solution... user input.edit -Try this. See main.au3. Very simple test.And just to clarify, this isn't about whether it's good code or not - it obviously isn't. I'm only addressing Valik saying it doesn't work. That's what things progressed to. It's all what Valik was talking about in his posts 6, 9, and 11. Edited January 1, 2007 by xcal How To Ask Questions The Smart Way Link to comment Share on other sites More sharing options...
hearurscream Posted January 1, 2007 Share Posted January 1, 2007 (edited) You are assuming that it will only be vars and strings. However, even if they DO only include vars and strings, if they are named the same way in each include file, whichever file was included last will overwrite the previous vars. If they weren't named the same variables, there would be no need for different lang files.You are the one that is wrong. Valik said if the include file is PURE code, it MIGHT work. You are reading the WHOLE post before you pass it off as nonsense I hope.EDIT: Sorry for the witty sarcasm. Valik is starting to corrupt me in his evil genius ways. Edited January 1, 2007 by hearurscream Infinity is a floorless room without walls or ceiling.Anyone who cannot cope with mathematics is not fully human. At best he is a tolerable subhuman who has learned to wear shoes, bathe, and not make messes in the house. Link to comment Share on other sites More sharing options...
Valik Posted January 1, 2007 Share Posted January 1, 2007 (edited) I know for a fact that the file is included, you twit. I wrote the damn code, I know what it does. The file is included, compiled or not, as one of the very first things AutoIt does. Based on your foolish assumption, the following script will run and/or compile: If True = False Then #include <NoFile> EndIf oÝ÷ Ø]¡ë'ßÛHµê뢻(ºØ¦çbj×¥ÈÚ-jȧW¥w¨~ëÊz+Åç.µçpØm«lr¸©µ:ò¶¬ü¨ºËbWhmmébz÷¦y«¢+Ø)5Í ½à ÐÀäØ°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½Ðí5 ÅÕ½Ðì¤)%QÉÕô±ÍQ¡¸($¥¹±Õ±Ðí9½¥±Ðì)¹%oÝ÷ Øò¢ë-Y]¢}ý¶éÝz»-jwa£§r[{ +ÈßÛ/z¼¬jezéeX§u©âÉnuë-jצz{)b:§¶«y÷«zwuø¥{ùb ¨§+ayéí·¢{^Û(~ØZµø¥{ùb Þë^¶¢Énuë-jצz{)b=«-¶¢{^Û(~Ø^çÞéÜy×â触Vzíè§r[zËZµéßåû¥N¡×¢²)ìz»^v)åw§¢Øb ¨å¡jÛajÙj{"³*.q©Ý¢Ê&z·¬r·°yÛ©²Û}«%¢x²Ø^ë.ÖµêÞƧv)àjYbÉnuíý²èvç²Ì§µ§-Æ¥+Ú'¡×'{¦¦W¨~ØZ¶)Úrب+-çèZ0x+"³k¥ªÚµçâë'jgéqÊ+v)à¶ayÊ&éí±«¢+Øì¹%¹ÔÌ)¹%oÝ÷ Ù«¢+Ø(ìMÉ¥ÁйÔÌ)%QÉÕQ¡¸(%5Í ½à ÐÀäØ°ÅÕ½ÐìÅÕ½Ðì°ÅÕ½ÐìÅÕ½Ðì¤(¥¹±ÕÅÕ½Ðí¹%¹ÔÌÅÕ½Ðì(oÝ÷ Ù Just because a file is included doesn't mean it's executed at the point of inclusion. I think you completely misunderstood about every single thing about how #include works. Edited January 1, 2007 by Valik Link to comment Share on other sites More sharing options...
hearurscream Posted January 1, 2007 Share Posted January 1, 2007 Valik, I'm just wondering here but, how many people have you thoroughly devoured on this forum? I don't know about anyone else, but I've spent hours just looking for threads that you have posted in, just to get a good laugh at how you completely destroy people. You are the God in my AutoIt Life, and that is no sarcasm! :"> Infinity is a floorless room without walls or ceiling.Anyone who cannot cope with mathematics is not fully human. At best he is a tolerable subhuman who has learned to wear shoes, bathe, and not make messes in the house. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 1, 2007 Moderators Share Posted January 1, 2007 Valik, I'm just wondering here but, how many people have you thoroughly devoured on this forum?I don't know about anyone else, but I've spent hours just looking for threads that you have posted in, just to get a good laugh at how you completely destroy people.You are the God in my AutoIt Life, and that is no sarcasm! :">How sad Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Recommended Posts