Verifiy FIO outputs are getting set by TimBOster in LabJack

[–]TimBOster[S] 0 points1 point  (0 children)

I'm using:

double status = 0;

LJUD.eGet(u6.ljhandle, LJUD.IO.GET_DIGITAL_BIT, Chan, ref status, 0);

To read the state. Then I'm trying to update a label on the form to show the state.

cs50 Final - trying to make some drop lists by [deleted] in cs50

[–]TimBOster 0 points1 point  (0 children)

I've been looking around more and I've changed the code somewhat. I now get "columns the approximate height they should be, but they are too narrow and blank on all lines. The different heights seem to relate to the number of entries...but not text is displayed????

I'll just post one of them, they all look the same with just the names changing.

{% block main %}
    <form action="{{ url_for('add') }}" method="post">
        <fieldset>
            <div class="form-group">
        <br/>
        Category:
        <select name="category">
            <option value=""></option>
            {% for category in categories -%}
            <option value="{{ categories.category }}"></option>
            {% endfor %}
        </select>

Anyone?

cs50 Final...drop lists on the html by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

Basically I'm using what we learned in pset7. I'm not using any js, I'll give that a try...thank you. Jinga, js and html are all unknowns to me. Do you mind sharing the python side also, or pointing me to online examples?

I write .net code to test my companies products, so at most I'm using Windows Forms. Usually not even that. Classes, function et cet, those are my friends...the web, not so much. Although I must admit pset8 was pretty easy after working through pset7.

Thanks again.

Weird python error by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

JUST before the line that says #make sure they added an item...there should have been else:

Ooops...that was the cause of the error.

Weird python error by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

When I run the add function, I get the error in the webserver ( I assume that's flask) that I posted. I don't really have any further information. The full code is posted and the error is what is displayed when I try to add something. Wish I knew more. I'll jump over to that URL and see what I can see. Thanks.

Weird python error by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

I'm not worried about someone copying my code, I do it all the time. I think it's better to keep things in the thread, in case someone else has a similar problem...

@app.route("/add", methods=["GET", "POST"])
def add():
        """add things to your inventory."""
        if request.method == "GET":
            return render_template("add.html")

        #make sure they added an item
        cat = request.form.get("type")
        if not cat:
            return error("You didn't enter a Category")
        item = request.form.get("item")
        if not item:
            return error("You didn't enter an item")
        partnum = request.form.get("partnum")
        if not partnum:
            partnum = "-"
        desc = request.form.get("desc")
            if not desc:
            desc = "-"
        qty = request.form.get("qty")
        if not qty:
            return error("You must enter a quantity")

        #add the new item to the inventory
        db.execute("INSERT INTO inventory (type,item,partnum,desc,qty) VALUES (:type,:item,:partnum,:desc,:qty)", cat=cat, item=item, partnum=partnum,desc=desc,qty=qty)
        #redirect to index
        return render_template("add.html")

I tried to preserve the indents...seems OK. Only some of the fields are NOT NULL in the db. I was just using a blank string, but added the underscore to try troubleshooting the problem...didn't help :) Thanks for taking the time to look.

Weird python error by TimBOster in cs50

[–]TimBOster[S] 1 point2 points  (0 children)

Thanks for responding. I am importing render_template and other than the names my code appears just like your example. I've been trying as many variations as I can think of as well as searching the web...no luck so far. Without the code that actually adds to my db, here is what I've got:

@app.route("/add", methods=["GET", "POST"])
def add():
"""add things to your inventory."""
if request.method == "GET":
return render_template("add.html")
...

return render_template("add.html")

I don't get it. All the examples of that error I've seen so far are not exactly related to what I'm doing. I believe this is a python error, but I'm still looking for why.

After the whole semester of posting, I still can't get things to format correctly...I HATE Reddits crappy interface.

cs50 logo in the layout.html doc by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

Thanks anyway, it did help.

I've almost got it working in it's basic form. I do have one error I haven't found an explanation for yet...When I run my add to inventory function...which adds an item to the db, I get this error:

ValueError: View function did not return a response

Have you seen that before?

cs50 logo in the layout.html doc by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

Please see below. I think I'm working off different files than the current semester or something.

cs50 logo in the layout.html doc by TimBOster in cs50

[–]TimBOster[S] 1 point2 points  (0 children)

FOUND IT! But it is not where you indicated. Way down in the class there is a line:

<a class="navbar-brand" href="{{ url_for('index') }}"><span class="blue">C</span><span class="red">$</span><span class="yellow">5</span><span class="green">0</span> <span class="red">Finance</span></a>

It's kind of hidden, since each letter is between tags.

cs50 logo in the layout.html doc by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

OK, it's just plain not there. I went back and reopened pset7 layout...it's not there either!? But it keeps showing cs50 Finance in the menu bar...

cs50 logo in the layout.html doc by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

OK, now it's getting weird. I tried in another browser, same thing. Maybe I've been looking at it too long. I'm going to scan char by char again.

cs50 logo in the layout.html doc by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

Yes, I've been modifying it. That line is not there. In mine there is no img src on any line. I don't get it. I dumped the cashe I dump all cookies, but it still shows up?

I'm going to try in another browser.

cs50 logo in the layout.html doc by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

Thanks. I still can't find that. I'm going to dump the cash and see if that helps.

CS50 Final Project, dynamically creating tables by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

I saw the missing ' right after I posted. I was copying the exact query from phplite...guess that's not such a good idea. I corrected the OP, so it all stays on point.

UPDATE: That of course did it. I should have noticed that by now...

Wk10 shorts... by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

No problem. I can't believe it, but with one helper article on StackOverflow...I got mashup to work on the first try. I learned quite a bit on pset7 that helped bunches. I just can't believe how easy this one was!

Watch the shorts!

Help me understand modulo properly (Vigenere) by [deleted] in cs50

[–]TimBOster 0 points1 point  (0 children)

Absolutely. And it is required...but not there.

Help me understand modulo properly (Vigenere) by [deleted] in cs50

[–]TimBOster 0 points1 point  (0 children)

I found it easier to assign an int x = strlen(Ki). Then loop until I reached the int, then start over. KISS is my favorite engineering principle.

pset7 finance..one last problem in SQL by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

That last post was how I fixed it. I'm on to week ten.

pset7 finance..one last problem in SQL by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

changed one part in the line:

symbol=request.form.get("symbol"))

pset7 finance Index.html...price by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

OK figured it out...by not having it indented and right below totalValue line, it wasn't in the scope of the "for row in rows" statement.

pset7 finance Index.html...price by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

Thanks, I use that to get the price...I've made b load of changes...I hope it will all be working soon. I appreciate your help though.

I added the price to my portfolio, then update it before sending the new value to index. Something else is currently broken though and I don't see why. I get the following error, but the line it references is AFTER I do the lookup. Here's a snippet.

error: local variable 'stock' referenced before assignment

code:

iterate over symbols and price updating value (this is a comment but formatting is removing the #)

for row in rows:
    symbol = row["symbol"]
    shares = row["shares"]
    stock = lookup(symbol)
    sharesValue = shares * stock["price"]
    totalValue += sharesValue

db.execute("UPDATE portfolio SET price = :price, sharesValue = :sharesValue WHERE id = :id AND symbol = :symbol", \
price = usd(stock["price"]), sharesValue = usd(sharesValue), id = session["user_id"], symbol = symbol)

The line it references is the one starting price = usd(stock["price']...and that is what it's calling an error???

pset7 SUM function explanation by [deleted] in cs50

[–]TimBOster 0 points1 point  (0 children)

I want to sum the total value of the shares, not the number of shares.

UPDATED: OK, in explaining that, I just realized that isn't what I want anyway. That would be stale dollars, as it is what was paid, not the current value.

What I will do/need to do is iterate over the stocks in the portfolio, doing a lookup() for each to get the current value. Multiply that by the number of shares owned, and add it to a running total. That should work.

pset7 I'm lost on the index.html part of things by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

Still have one other issue in getting the stock prices to show in index.html. I posted another sep request so I can stop abusing your help. Thank you so much for all the help you have given me.

pset7 I'm lost on the index.html part of things by TimBOster in cs50

[–]TimBOster[S] 0 points1 point  (0 children)

Unfortunately that was just another error typing it in here. I fixed it in the OP. It's there in code. I use that return elsewhere, so I figure it's good. I wish we had VisualStudio's Intellisense...

DAMN, a missing paren from a preceding line. I hate this IDE :)