Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

attach variable to string

Hi,

sorry for asking many questions, but I'm new to Python.
So, I have an inline-script which sends triggers to the serial port, like this:
port.sendMessage("overview")
These triggers show then up in the logfile of the program that is connected via the serial port (which is an eye-tracker, but I think this doesn't matter for my question).

What I would like to do is: Instread of just "overview" (or "summary" or "draw") I would like to send "overview" and a variable, so that I know which overview (or which summary or which draw) it is. I have these variables defined in a loop and would like to attach them to the string which I send (like port.sendMessage("overview"&var.jar)) but I don't know how I can do that.

Can you give me any tips how to do this or where to look it up?

Thanks a lot!
Pia

Comments

  • edited May 2017

    Hi Pia,

     port.sendMessage("overview " + str(var.jar)) 
    

    Cheers

  • Thanks a lot!!

  • Thanks again. Now I have another, very much related, problem.
    So some of my variables have this format (in the inline-script):
    [color_of_draw[jar_nr]]
    (So the variable names are color_of_draw1, color_of_draw2, and so on.)
    I try to send those to the serial port aswell. Here is how I tried that:
    color_of_draw_var = "color_of_draw" + str(var.jar_nr) port.sendMessage("Draw Jar" + str(var.jar_nr) + "Draw Marble" + str(var.color_of_draw_var))
    So, as you see, I tried to create a variable color_of_draw_var which I then use. But it doesn't work. It sais "The variable 'color_of_draw_var' does not exist."

    How can I create that variable?

  • Hi Pia,

    you create a variable called color_of_draw_var and in the next line you use a variable called var.color_of_draw_var. Those are not the same, you see?

    Eduard

    Buy Me A Coffee

  • Hi Pia, color_of_draw_var (first line of your code) is unequal to var.color_of_draw_var (second line of your code)

    Cheers

  • Thank you! It works (I didn't know that I didn't had to put the ´´var.´´), but I noticed it's not what I wanted.

    So, if I do it like this:
    color_of_draw_var = "color_of_draw" + var.jar_nr port.sendMessage("Draw Jar" + str(var.jar_nr) + " Draw Marble " + str(color_of_draw_var))
    It prints for example (if the Jar was 2) color_of_draw2. I see that that makes sense, but I didn't want it to print color_of_draw2 as a text but the contents of my variable called color_of_draw2.

    Here are my variables:

    And I would like to print the contents of those (to the serial port).

    Any idea how I can do that?
    Thanks!

  • Replace:

    color_of_draw_var = "color_of_draw" + var.jar_nr

    With

    color_of_draw_var = exp.get("color_of_draw" + var.jar_nr)

    Buy Me A Coffee

  • Thanks a lot, it works!! :smiley:

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games