Announcement

Collapse
No announcement yet.

String Manipulation - please help

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • String Manipulation - please help

    I have a code and dont know how to include a variable name "asubject1" in a TextFile.ReadToString address. The variable has the subject name which determines the location.

    Example Code:


    if asubject1 then

    Qans2 = TextFile.ReadToString("AutoPlay\\Docs\\pool\\asubj ect1\\q2011\\2ans.txt");

    if Qans2 == "1" then Image.Load("Ans1", "AutoPlay\\Images\\tick.png");

    elseif Qans2 == "2" then Image.Load("Ans2", "AutoPlay\\Images\\tick.png");

    elseif Qans2 == "3" then Image.Load("Ans3", "AutoPlay\\Images\\tick.png");

    elseif Qans2 == "4" then Image.Load("Ans4", "AutoPlay\\Images\\tick.png");
    end
    end
    Please i need help with example. Thanks.

  • #2

    Code:
    Compare = String.CompareNoCase(sQuans, "1");
    if (Compare == 1) then

    Comment


    • #3
      herrin, sincerely i dont seem to understand what you mean i should copare. can you elaborate a little on the example?

      Compare = String.CompareNoCase(sQuans, "1"); if (Compare == 1) then
      Note that my issue is "asubject1 variable, not the Qans as you referred.

      Comment


      • #4
        I mean this line of code:

        Qans2 = TextFile.ReadToString("AutoPlay\\Docs\\pool\\asubj ect1\\q2011\\2ans.txt");


        This is what im trying to do:

        Qans2 = TextFile.ReadToString("AutoPlay\\Docs\\pool\", asubject1.. "\\q2011\\2ans.txt");


        I Mean, how do i do the above properly?

        Comment


        • #5
          Code:
          Qans2 = TextFile.ReadToString("AutoPlay\\Docs\\pool\[COLOR=#FF0000][B]\[/B][/COLOR]" .. asubject1.. "\\q2011\\2ans.txt");
          - Did you forget a backslash there? Without two backslashes, you'll be escaping the next character instead. I later noticed a comma in stead of the concatenation operator as well
          Last edited by Imagine Programming; 09-21-2019, 06:03 PM.
          Bas Groothedde
          Imagine Programming :: Blog

          AMS8 Plugins
          IMXLH Compiler

          Comment


          • #6
            Something like this, you mean?
            Code:
            Qans2 = TextFile.ReadToString("AutoPlay\\Docs\\pool\\asubject1\\q2011\\2ans.txt"); 
            Image.Load("Ans"..Qans2, "AutoPlay\\Images\\tick.png");


            It's hard to discern exactly what you're after - but try my example, attached.
            Attached Files

            Comment


            • #7
              Originally posted by Imagine Programming View Post
              Code:
              Qans2 = TextFile.ReadToString("AutoPlay\\Docs\\pool\[COLOR=#FF0000][B]\[/B][/COLOR]" .. asubject1.. "\\q2011\\2ans.txt");
              - Did you forget a backslash there? Without two backslashes, you'll be escaping the next character instead. I later noticed a comma in stead of the concatenation operator as well

              Thanks a million bro, you have solved my problem and have well implemented it. It works great!

              I actually forgot the 1 back slash and have always think a comma in between variables but you have cleared me. Thanks again.

              Comment


              • #8

                I doubt the problem was the backslash.........




                Code:
                [ATTACH]n303952[/ATTACH]

                Comment


                • #9
                  herrin, your code is now downloadable so how can i confirm your doubt? please correct the issue so we can look at it.

                  Comment


                  • #10
                    Originally posted by Kasito View Post
                    Thanks a million bro, you have solved my problem and have well implemented it. It works great!
                    I actually forgot the 1 back slash and have always think a comma in between variables but you have cleared me. Thanks again.



                    if you have solved the problem what do you need to know if my doubt was founded?

                    Comment

                    Working...
                    X