Does anyone know how to set a variable with randInt() on Ti-84 Plus CE? - ti-basic

I was just messing around writing a slot machine program on my PlusCE and I tried to run this:
:randInt(111,999,1)->A
But it won't save to the variable
Any ideas?

randInt returns a list, even if you only want one trial. So you need to store the result in a list variable.

Related

String indices must be integers not str? What's going on here

My Code:I'm learning to write the basic intro to a finance program that I found on YouTube. All necessary packages have been installed and updated just to make sure. In line 19 using the get_data_yahoo function is the way I'm calling upon the stock variable wrong?
Thanks
I tried updating all packages involved, closing the program, tried to change the stock variable to read as an integer using int(stock) nothing has worked.

How do I detect if two variables have the same value

I was making a discord bot and I want to make an account system, what my program supposed to do is to keep on finding a registered user by checking on the .json file over and over until it finds the two variable with the same value, problem is I can't find anything online for a solution. I just need a code for it :)
Sure! Try something like this:
with open('filenamehere', 'r') as f:
# Add Code to add values to a list called x here
After this, we can go ahead and do one of two things:
Run a simple if value is in list x, or
Run a for loop on the list until it reaches the value required.
Either way should give you the desired outcome. Sorry I was a little vague, your question was as well.

How to pass arrays to AWX/Ansible Tower

I'm calling AWX template from ManageIQ. I'm passing 9 variables to the playbook (with prompt on launch active). The playbook is successfully called, and all of the vars come through. However two of the vars are supposed to be arrays. Instead they come through to AWX as strings: e.g., '["chefclient"]' instead of ["chefclient"].
I have confirmed that these vars are indeed of type array in ManageIQ before I pass them to the AWX template.
Any clue why this is happening? Do all vars get irresistibly converted to strings? How do I fix this?
Thank you!
According to the RedHat developers on Gitter.im, this is a shortcoming in the launch_ansible_method in ManageIQ. I.e., it always converts arrays to strings. We have opened an issue on GitHub to address this.
I have basically had a variable in ansible tower/awx that takes input as Text with server names as array/List. example: ["node1","node2","node3"] and once job is launched I can see the variable in the extra variables as '["node1","node2","node3"]'. I'm not sure about reason why it does that but it doesn't effect your subsequent ansible operations on that variable. Not all variables gets single quotations only when you use array/List.
I have tried to replicate this on my end with AWX installed locally. I have passed v_packages variables data as ["apache2","nginx"]. I don't see that issue now.

Efficient access to last value in large list in python

I am using a large list in my python script and need to access the last value of this list very often, while the list doesn't change that much. Should I simply access it directly (longList[-1]) or is it preferable to assign the last value of the list to a variable (lastValue = longList[-1]) and use this variable instead. Of course I have to update the variable when the list changes.
From a functionality point of few it is the same, I am more concerned about the performance gain it could bring.
List access takes O(1) time. So, there is no need to assign it to a variable.

capturing what keys were used to launch vbscript

I have an application that has 'macro' capabilities. When I map some keys on the keyboard to perform the 'macro', I can also have it launch vbscript instead.
What i'd like to try and do is within my vbscript figure out what keys were used in order to launch the script. Is it posible to do this? Could there be a way in vbscript to figure out what keys were last touched on the keyboard and then I could apply my logic.
The purpose of doing this is to keep the code in a single .vb file instead of several seperate .vb script files(one for each keyboard mapping, possible 3-4). Obviously we are looking to just maintain 1 file instead of multiple files with essentially the same code in each one.
I am leaning towards the idea that this is not possible, but i figured this would be a worthy question for the masses of StackOverflow. Thanks for the help everyone!
What you are asking for is not possible.
Can you change your VBScript to accept parameters and then call it with a different parameter based on which hotkey was selected?
I agree with aphoria, the only way to make something like this possible is if your keyboard mapping software allows you to assign a script/command with parameters/arguments. For example if you used
c:\Temp\something.vbs
then you would change this to
%WINDIR%\system32\wscript.exe c:\temp\something.vbs "Ctrl-Alt-R"
Then in your vbscript code you could collect the argument using the wscript.Arguments object collection to do actions based on what argument/parameter was passed. See the following two links for more info:
http://msdn.microsoft.com/en-us/library/z2b05k8s(VS.85).aspx
http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept04/hey0915.mspx
The one possible approach you may use is to install keylogger and read its log in your VBScript.
For example save script start time in the very beginning of the script
StartTime = Timer()
and then read one log record of your keylogger before this time.

Resources