none
Changing the content of a variable RRS feed

  • Question

  • I'm using a switch as part of the programming logic.  I set the value of the switch to 1 as such:

    First_Pass = 1

    Once have executed the some code I want to change the value to 0.  I'm doing this as follows:

    First_Pass = 0 

    The above does not work, I've tried several method and nothing works.  

    How do I change the content of a variable.  It seem so simply but is so hard.

    Thanks

     

    • Moved by Bill_Stewart Tuesday, December 5, 2017 3:12 PM Unanswerable drive-by question
    Tuesday, October 24, 2017 7:37 PM

All replies

  • What language are you using?  and provide your code. 

    Ashidacchi

    Tuesday, October 24, 2017 7:49 PM
  • I'm using Powershell, I just want to change the content of:

    First_Pass from a 0 to a 1

    Code: 

    First_Pass = 0 

    First_Pass = 1

    thanks

    Tuesday, October 24, 2017 7:55 PM
  • First pass = 0

    is not PowerShell code.  It is just text. You must assign the variable.

    Start with this to learn what a variable is and how to use it:

    Learn PowerShell: https://mva.microsoft.com/en-us/training-courses/getting-started-with-microsoft-powershell-8276

    It is a short and free video tutorial from Microsoft superstars.


    \_(ツ)_/

    Tuesday, October 24, 2017 8:00 PM
  • I  apologize the code should have been as follows:  

    $First_Pass = 0

    The variable is initial set to 0, once code is executed I want to change the value/content of $First_Pass to 1

    $First_Pass = 0

    I learning of the fly here and thanks for the video I will view it now.  By chance will it help with my problem. 

    thanks

    Tuesday, October 24, 2017 8:10 PM
  • Your problem is that you know so little that you cannot even begin and you aren't even able to ask a question that makes any sense technically.  Until you know more any attempt to figure out what you are asking will fail.  The video will change that.


    \_(ツ)_/

    Tuesday, October 24, 2017 9:51 PM
  • I ask that you not condemn me for trying to learn powershell I’ve  have reviewed the suggested video as well as others and read articles, started books for six months.  I’ve got to start somewhere.

    I’m just trying to build a SQL statement to be submitted to SQL server, then export the result to a csv file.  The contents is coming from a file that contains and id and date, based on that I building the where clause.  

    The video did help.  

    Thanks

    Tuesday, October 24, 2017 10:55 PM
  • I am not condemning you.  From any of us that know PowerShell it is extremely obvious that you haven't taken the time to do a basic course or you would not be asking the question you are asking and you would not be trying to build a "WHERE" statement in that way.

    You cannot learn PowerShell by just reviewing a video.  You must study it and do all of the exercises and examples until you understand what it is telling you. 

    The question you have asked has no variables, no PowerShell code and just doesn't make any sense.

    Please,  for your own sake, watch the video until you understand what it is teaching you.  In the end you will be able to ask a question that makes sense and you will probably not need to ask the question.

    If after months you do not know what a variable is and how to assign it you need to go back and do the learning again.


    \_(ツ)_/

    Tuesday, October 24, 2017 11:02 PM
  • So maybe I used the wrong terminology I'm really trying to change the content of and object. 

    I fully understand the concepts of objects, properties and methods. I'm a programmer of more than thirty years.  I have a project that I'm trying to complete.  I felt that using Powershell would help re-enforce what I've learned, I may have chosen the wrong tool for the job but I believe that I'm almost to the end and I don't have time to change at this point.  If I could just change the content of the object for my switch. 

    I have learned a lot from this exercise so all is not lost.    

    You help has been greatly appreciated and I hope it will continue. 

    Thanks


    • Edited by Louisb Tuesday, October 24, 2017 11:55 PM
    Tuesday, October 24, 2017 11:53 PM
  • Now you are just making things up.  Sorry but I am not into playing childish games. 

    Here is that last bit of knowledge.

    $object = 5

    There. An object has been changed.  I hope that is what you want.  If not. ....


    \_(ツ)_/

    Tuesday, October 24, 2017 11:57 PM
  • Thank you very much. 

    I just figure out how the if clause that was my problem with the switch.  I should have used the equal method. 

    thanks

    Wednesday, October 25, 2017 12:31 AM
  • What "if"  there is no if anywhere ein this thread.  How can you imagine that anyone can possibly help you if you post no code and no sensible information.  We cannot read your mind or see your computer screen.

    \_(ツ)_/

    Wednesday, October 25, 2017 12:34 AM