Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

In one way, it depends on whether you are targetting iOS or Android. For the former, you would natively use Swift, while for the latter you would natively use Java.

However, there are a number of tools for cross-platform development, of varying quality, some of which work with C#, JavaScript, Clojure, Python, or even VB.Net, so you have a variety of options for this. While it wouldn't be ideal, you can work in VB.Net if you choose (though not VB6, which is long, long out of support).

My own choice would be Clojure, but then I am insane like that. :-)

As for database use, it would depend on whether you need the database to be local to the mobile device, or remote on a server. For device-local databases, you would usually use SQLite, which is somewhat more limited than a full SQL RDBMS. Server databases can use whatever you choose, more or less, but you'd need some means of connecting to it remotely, which usually means some sort of server-side programming in addition to the SQL database.

rproffitt commented: My thought is VB6 is Blue Pill, Clojure and such is Red Pill. +0
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Just as an aside, since you know that it is in the range 0..30, have you considered declaring value as Byte (and casting the string using CByte()) ? That would at least help eliminate one possible source of error (since you would never get a negative value).

Perhaps try writing a utility function to force saturation, like this (warning, untested code, it has been a while since I coded in VB.Net):

Public Function CByte_Saturate_Range(data As String, min As Byte, max As Byte) As Byte
    Dim value As Byte
    Dim swap As Byte

    If min = max Then
        Return min
    End If

    If min > max Then
        swap = min
        min = max 
        max = swap
    End If
     ' convert to a Short first, then force it to a positive absolute value
     ' before converting it to Byte
    value = CByte(Math.Abs(CShort(data))
    If min > value Then
         value = min
    ElseIf value > max Then
         value = max
    End If
    Return value
End Function

You would call it like so:

    value = CByte_Saturate_Range(Label10.Text, 0, 30)
    If value > 0 Then
        value = value - 1
    Else
        Form11.Button5.PerformClick()
        Timer1.Stop()
    End If
    label10.Text = CStr(value)

While this might seem overkill, it would at least separate the logic for converting and saturating the value from that of testing for the timer value.

Actually, let me back up a bit before I finish: why is the timer based on a Label's value in the first place? That might help us understand the wider goal involved.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I can't say if it the main source of the problem, but the line If value >= 0 Then has the test reversed; it should be If value <= 0 Then instead.

This doesn't explain why it fails at exactly zero, but you'd be better off correcting it anyway.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

As Rproffitt said, please make your own new threads rather than resurrecting long-dead ones.

As for the error code, that was explained in detail earlier in this thread: it indicates that you tried to read a number from a file, and got something other than a number, as defined here. The likely solution is to add a check for an end-of-file in the loop, using the function eof().

Though from the screenshot, you might be using Turbo Pascal, where the error indicates a malformed string. The correct solution to this is Don't Use Turbo Pascal.

rproffitt commented: Turbo Pascal is the Blue Pill. +16
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Do you have a program class (i.e., one with a main() method) which you could share with us, so we could test the GamePanel class ourselves? Even a minimal test class would help us.

If you have a public repo you could share with us, that would help immensely. You definitely should be using version control with an offsite repo, if you can, as it is crucial for ensuring the ability to monitor the progress of even small projects.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Before I address the question, allow me to trim the includes list a bit, removing some which are either redundant or not actually valid under standard C++ :

#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
using namespace std;

Mind you, using using namespace std; isn't a great idea either, since it essentially undermines the whole point of having a std namespace in the first place, but for homework it is at least acceptable.

As for the actual question, the first thing I take note of is that there looks to be two off-by-one errors in the sorting algorithm.

        for (int i = 1; i < size; i++)  // should be 'i=0'
        {
            for (int j = 1; j <size-i; j++) // should be 'j=0'
            {

Arrays in C++ are zero-indexed, meaning that the first element of the array arry is arry[0], the second is arry[1], and so forth to arry[size-1]. These off-by-one errors could be the source of the segfaults, though I would have to take a closer look than I have to be certain.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Traditionally, sets are represented as bitfields, which could then be manipulated with the bitwise operators - & for union, | for intersection. Since you know the whole set has at most 20 elements, the representation can fit into a single 32-bit unsigned integer.

Also, would it make more sense to make a class Set to factor all of the intersection and union logic out into one place?

By combining these approaches you'd be saving yourself a great deal of effort, I think.

xrjf commented: Right, only note '&' is for intersection and '|' for union. +8
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Did you have a question, or need assistance in some way?

vaishnavi_13 commented: i need to show the intersection of set a and b & set b and c & set c and set a and union pf set a,b and c in output but it is not displaying. +0
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

You would need some sort of server-side scripting (PHP, ASP.NET, Node.js, Django, Ruby on Rails - something like those) to query the database and insert the dataset into the page before it is served. Even if you do some of the work client-side (e.g., with AJAX), you would still need server-side support for querying the database.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

You might want to try the OSDev Forums as they have more specialized knowledge.

However, you might want to read this wiki page first, as it voices some of the issues faced in using Python (and other languages which are usually interpreted rather than compiled) for OS-Dev. I would also read all of the wiki pages listed here before proceeding at all, as they will give you a better idea of just how huge an undertaking this is.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

You would move the method out of the class declaration, preferably moving the declaration, implementation, and main() into separate compilation units.

line.h:

int xmax,ymax,xmid,ymid;
class Line
{
public:
  int x1,x2,y1,y2,ch;
};

line.cpp:

#include <cmath>   // in TC++ this would be '<math.h>'
#include "line.h"

void Line::bss(int x1,int y1,int x2,int y2)
{
  int dx,dy,x,y,s1,s2,ex,e,i,flag=0,temp;

  dx=abs(x2-x1);
  dy=abs(y2-y1);
  x=x1;
  y=y1;
  putpixel(x+xmid,ymid-y,15);

  if(x2>x1)
    {
      s1=1;
    }
  if(x2==x1)
    {
      s1=0;
    }
  if(x2<x1)
    {
      s1=1;
    }
  if(y2>y1)
    {
      s2=1;
    }
  if(y2==y1)
    {
      s2=0;
    }
  if(y2<y1)
    {
      s2=1;
    }
  if(dy>dx)
    {
      temp=dx;
      dx=dy;
      dy = temp;
      ex = 1;
    }
  else
    ex=0;

  e=2*dy-dx;
  i=1;

  do
    {
      while(e>0)
        {
          if(ex==1)
            x=x+s1;
          else
            y=y+s2;
          e=e-2*dx;
        }
      while(e<0)
        {
          if(ex==1)
            y=y+s2;
          else
            x=x+s1;

          e=e+2*dy;
        }

      switch(ch)
        {

        case 1:
          putpixel(x+xmid,ymid-y,15);
          break;

        case 2:
          if(flag==0)
            {
              putpixel(x+xmid,ymid-y,15);
              delay(1000);
              if(i%5==0)
                {
                  if(flag==1)
                    flag=0;
                  else
                    flag=1;
                }
              break;

            case 3:
              if(flag==0)
                {
                  putpixel(x+xmid,ymid-y,15);
                  delay(1000);

                  if(i%5==0)
                    {
                      if(flag==1)
                        flag=0;
                      else
                        flag=1;
                    }
                  if(i%3==0)
                    {
                      putpixel(x+xmid,ymid-y,15);
                      delay(1000);
                    }
                  break;

                case 4:
                  if(flag==0)
                    delay(1000);
                }
              else
                {
                  if(i%3==0)
                    {
                      putpixel(x+xmid,ymid-y,15);
                      delay(1000);
                    }
                }
              break;
            case 5:
              putpixel(x+xmid,ymid-y,15);
              break;
            }
          i =i+1;
          delay(50);
        }
      while(i<=dx);
    }
}

main.cpp:

#include <iostream>
#include <cstdlib>
#include <cmath>
#include <graphics.h>
#include "line.h"
using namespace std;



int main()
{
    int gd = DETECT,gm;
    int x1,y1,x2,y2,thick,wy,i;
    Line B;
    cout<<"Enter two end pointsof line:\n";
    cin>>x1>>y1;
    cin>>x2,y2;

    while(1)
    {
        cout<<"\nEnter the Style\n";
        cout<<"1.Simple\n";
        cout<<"2.Dash\n";
        cout<<"3.Dash dot\n";
        cout<<"4.Dot\n";
        cout<<"5.Thick\n";
        cout<<"6.Exit\n";
        cout<<"Enter your style\n";
        cin>>B.ch;
        if(B.ch==5)
        { 
            cout<<"Enter the thickness of line:";
            cin>>thick;
        }
        initgraph(&gd,&gm,NULL);
        xmax=getmaxx();
        ymax=getmaxy();
        xmid=xmax/2;
        ymid=ymax/2;

        if(B.ch<=4)
        {
            B.bss(x1,y1,x2,y2);
            delay(300);
        }
        else
        {
            B.bss(x1,y1,x2,y2);
            delay(300); …
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

No one here is going to open up some random Word document in MS Word, where there could be random macro viruses in it.

Fortunately for you, I use LibreOffice instead, and the macros are all disabled. So, let me post the code for you as you were requested to do in the first place:

#include<iostream.h>
#include<stdlib.h>
#include<graphics.h>
#include<math.h>
using namespace std;

int xmax,ymax,xmid,ymid;
class Line
{
public:
  int x1,x2,y1,y2,ch;
  void bss(int x1,int y1,int x2,int y2)
  {
    int dx,dy,x,y,s1,s2,ex,e,i,flag=0,temp;

    dx=abs(x2-x1);
    dy=abs(y2-y1);
    x=x1;
    y=y1;
    putpixel(x+xmid,ymid-y,15);

    if(x2>x1)
      {
        s1=1;
      }
    if(x2==x1)
      {
        s1=0;
      }
    if(x2<x1)
      {
        s1=1;
      }
    if(y2>y1)
      {
        s2=1;
      }
    if(y2==y1)
      {
        s2=0;
      }
    if(y2<y1)
      {
        s2=1;
      }
    if(dy>dx)
      {
        temp=dx;
        dx=dy;
        dy = temp;
        ex = 1;
      }
    else
      ex=0;

    e=2*dy-dx;
    i=1;

    do
      {
        while(e>0)
          {
            if(ex==1)
              x=x+s1;
            else
              y=y+s2;
            e=e-2*dx;
          }
        while(e<0)
          {
            if(ex==1)
              y=y+s2;
            else
              x=x+s1;

            e=e+2*dy;
          }

        switch(ch)
          {

          case 1:
            putpixel(x+xmid,ymid-y,15);
            break;

          case 2:
            if(flag==0)
              {
                putpixel(x+xmid,ymid-y,15);
                delay(1000);
                if(i%5==0)
                  {
                    if(flag==1)
                      flag=0;
                    else
                      flag=1;
                  }
                break;

              case 3:
                if(flag==0)
                  {
                    putpixel(x+xmid,ymid-y,15);
                    delay(1000);

                    if(i%5==0)
                      {
                        if(flag==1)
                          flag=0;
                        else
                          flag=1;
                      }
                    if(i%3==0)
                      {
                        putpixel(x+xmid,ymid-y,15);
                        delay(1000);
                      }
                    break;

                  case 4:
                    if(flag==0)
                      delay(1000);
                  }
                else
                  {
                    if(i%3==0)
                      {
                        putpixel(x+xmid,ymid-y,15);
                        dekay(1000);
                      }
                  }
                break;
              case 5:
                putpixel(x+xmid,ymid-y,15);
                break;
              }
            i =i+1;
            delay(50);
          }
        while(i<=dx);
      }
  };

  int main()
  {
    int gd = DETECT,gm;
    int x1,y1,x2,y2,thick,wy,i;
    Line B;
    cout<<"Enter two end pointsof line:\n";
    cin>>x1>>y1;
    cin>>x2,y2;

    while(1)
      {
        cout<<"\nEnter the Style\n";
        cout<<"1.Simple\n";
        cout<<"2.Dash\n";
        . cout<<"3.Dash dot\n";
        cout<<"4.Dot\n";
        cout<<"5.Thick\n";
        cout<<"6.Exit\n";
        cout<<"Enter your style\n";
        cin>>B.ch;
        if(B.ch==5)
          {

            cout<<"Enter the thickness of line:";
            cin>>thick;
          } …
rproffitt commented: Thanks for your effort here. It does make me wonder how they put in 200 lines of code and only now figured out it was never going to be in Turbo C. +16
vaishnavi_13 commented: So to remove inline what exactly i should do?? +0
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

It would have been better if you'd posted more details in the threads you'd already started, rather than re-posting mre or less the same thing in a new post each time. While you've given us some more details, it still isn't enough to do anything with, I'm afraid. We really need to see what you have tried yourself already.

Also, don't tag in languages which aren't connected to the problem at hand, please.You've said it is in VB.Net, so why mention Python and PHP?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Correction: the strings would be left-justified, not right-justified.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Wait, what? You mentioned Perl in the thread title, but then you added tags for C, C++, and Python. Which is it?

Also, the description doesn't match the illustrative example. How do you need it laid out?

Assuming you do indeed mean Perl, and that you are in shell rather than a GUI window, then there are several options (Perl always has multiple solutions). The simplest, but also most fragile, approach is to use sprintf() with a suitable format string, like so:

sprintf("%20s%20s%20s%20s", "Time", "Column_1", "Column_2", "Column_3")

This example will print the data right-justified in columns of 20 characters. However, there are a number of better approaches, such as the Text::Column library in CPAN. A quick search on CPAN for 'Column' finds a few others you could try, while a similar search on 'tabulate' finds even more, some of which would probably suit your intended result.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

A quick search finds this list of free books on Python. Of these, I would recommend Think Python personally, though I don't know all of the others so there may be a better one in the list if you check.

As for videos, I would suggest Tech With Tim's "Complete Python Course for Beginners", though I will mention that the full video is rather long.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Let's step back and look at the details, such as

  • What sort of game are we talking about? The mention of tokens makes it sound like it is suppose to be a simulated slot machine or arcade machine, but the 'online billing' part is a bit confusing.
  • What is the time management part for?
  • You tagged both 'JavaScript' and JQuery' in addition to VB.Net. Is the game supposed to be web-facing, and if so, how is it to be hosted? Is the VB.Net part supposed to use ASP.Net scripting server-side?
  • Are you using a Version Control System (e.g., Subversion, Git, Team Foundation Service) and an offsite repo - which you should, even for a small class project like this - and if so, could you give us a link to the repo?

At this point, we don't know enough about the project to even tell what the assignment actually is, never mind the fact that we'd need to see what you have attempted already to be able to give advice.

David_239 commented: And our prof gives us less time to make it +0
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Tech fora? Not so much these days, though I still check the OSDev.org forum from time to time, and am on the Discord for the Craft Computing YouTube channel. I am mostly on LGBT+ related Discords lately, and the forum and Discord for the Whateley Academy web serial novel series.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I believe Pritaeas was referring to using https://wetransfer.com, a website that allows secure anonymous transfers of files - sort of similar to Google Drive, except designed specifically so you can hand a link to someone to access it, rather than you having to set their account's permissions.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

If you have version control set up, is there any way to send the users an earlier build to see if that version installs?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

If you don't mind me asking, do you have a publicly accessible version-control repository for your code? It would make it much easier for us to review the program, if necessary.

However, I suspect that the problem isn't with the program itself, but rather with the installer - especially if it is in VB6, rather than VB.Net. Maintaining VB6 has become more and more difficult as support for it has dropped away, and Microsoft themselves have been pushing users to migrate to VB.Net for almost 20 years now (.NET Framework being introduced in early 2002). While Windows 10 generally doesn't have a problem with 32-bit programs, Windows 11 support for older programs seems less certain.

What can you tell us about the failure mode? Do they get any error messages?

Have you tested the installer yourself on one or more different machines other than your development platform?

What version of Windows are you developing on, and what versions of Windows are your clients running it on? I am specifically wondering if any of them are running Windows 11.

Also, are any of the clients reporting a problem using new Intel CPUs (the ones with separate performance and efficiency cores)? Some older programs are having problems with the big.LITTLE architecture - especially ones which rely on 32-bit support, as would be necessary for VB6 - and your installer could be as well. I assume that this is unlikely, given how new those systems are, but I thought I would bring it …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

As an aside, do you mind if I ask how happen to be working in VB6? Is this a legacy application?

rproffitt commented: This was the last year our office would do anything with VB6 apps. Now we'll only talk about migration. +16
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

What exactly are you taking the average of - the rows, the columns, or all of the values together?

Zerrin_1 commented: all of the values together, but I found the answer, thank you +0
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

The msqli_multiquery() function returns a boolean value, but you seem to be expecting a query dataset (mysqli_result). To get the first query's dataset, you would use mysqli_next_result() followed by either mysqli_store_result() or mysqli_use_result().

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I'll be honest with you, I know very little about statistical analysis and plotting, though I did help someone in this forum with a related plotting issue before.

I did find this article on LOWESS Regression in Python which could help with this aspect of it.

In addition to NumPy and Pandas, that tutorial uses a library called statsmodels, which had an existing implementation of the LOWESS algorithm.

It also uses the Plotly library for rendering the graphs (I was expecting that they would use MatPlotLib, which is widely used for this sort of problem, but presumably there is some advantage to using Plotly - I am not especially familiar with either of them so I can't say). Since I was going to ask how you intended to render the plots, I feel this might be something you need.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Sorry to keep serial posting, but I also noticed the following line:

            'storedquery_id': 'fmi::observations::weather::monthly::simple',

Presumably, there is a form of this parameter which can specify a daily query rather than a monthly one. I don't know enough about the FMI API to determine what that query would be, however, nor where I would find that information.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

The code doesn't do what you think it does. It generates a 3x3 array and then populates it with random values. Frankly, it isn't very good code in general, but the main problem is that it doesn't do what it claims to.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I've done some more experiments, and one of the things I've learned is that FMI only has records for the first day of each month, for some reason. This code will get all of the entries for a period, and when I run it there are only entries for the first of the month. Note that this returns a somewhat different format than that returned by the existing get_monthly_obs() function.

    @classmethod 
    def get_period_obs(cls, place, start_date, end_date, maxlocations=5):
        """
        get multiple observations over a period of dates.

        in:
            place [str]
            start_date [datetime]
            end_date [datetime]
            maxlocations [int] (optional)

        out:
            dictionary with date of the observation,  
            tuple of locations and times keys,
            and dictionary of parameter names and values as strs
            tmon <=> temperature
            rrmon <=> rainfall
        """
        # parameters for the API request
        parms = {
            'request': 'getFeature',
            'storedquery_id': 'fmi::observations::weather::monthly::simple',
            'place':place.lower(),
            'maxlocations':'%d'%maxlocations,
            'starttime': start_date.strftime('%Y-%m-%dT00:00:00'),
            'endtime': end_date.strftime('%Y-%m-%dT00:00:00'),
            }
        parms.update(FmiApi.fixed_params)   # add the fixed parameters to the parameter list       

        # perform the API request
        try:
            resp = requests.get(FmiApi.base_url, params=parms, stream=True)
        except:
            raise Exception('request failed')

        # check the request's status code for errors
        if resp.status_code != 200: raise Exception('FMI returned status code %d'%resp.status_code)

        # parse the raw XML data into an element tree object, exit on failure 
        resp.raw.decode_content=True
        try:
            root = etree.parse(resp.raw)
        except:
            raise Exception('parsing failed')

        # destructure the XML data to get the individual data elements
        members = root.xpath('//wfs:member', namespaces=FmiApi.namespaces)
        weather = {}
        for member in members:
            ptime = member.xpath('.//BsWfs:Time', namespaces=FmiApi.namespaces)[0].text.strip()
            if not ptime in weather:
                weather[ptime] = {}
            ppos = member.xpath('.//gml:pos', namespaces=FmiApi.namespaces)[0].text.strip() …
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I'll post the code I've been working on myself, but I am not sure if it really is going where you want it to. One thing I want to ask about is, would it be better to read the entire dataset for the period being studied rather than repeatedly requesting a large number of days individually?

import datetime
import requests
import lxml.etree as etree
from pprint import pprint
import pickle
import pandas as pd
import numpy as np

class FmiApi:
    """
    a minimalistic wrapper for the Finnish Meteorological Institute API
    """
    base_url = 'http://opendata.fmi.fi/wfs'
    fixed_params = {
        'service': 'WFS',
        'version':'2.0.0',
    }
    namespaces = {
        'wfs':'http://www.opengis.net/wfs/2.0',
        'gml':'http://www.opengis.net/gml/3.2',
        'BsWfs':'http://xml.fmi.fi/schema/wfs/2.0'
    }

    def __init__(self):
        pass

    @classmethod
    def get_daily_obs(cls, place, year, month, day, maxlocations=5):
        """
        get daily simple observation

        in:
            place [str]
            year [int]
            month [int]
            day [int]
            maxlocations [int] (optional)

        out:
            dictionary with tuple of locations and times keys
            and dictionary of parameter names and values as values
            tmon <=> temperature
            rrmon <=> rainfall
        """
        sdate = str(datetime.date(year,month,day)) # current date as a string

        # parameters for the API request
        parms = {
            'request': 'getFeature',
            'storedquery_id': 'fmi::observations::weather::monthly::simple',
            'place':place.lower(),
            'maxlocations':'%d'%maxlocations,
            'starttime': sdate + 'T00:00:00',
            'endtime': sdate + 'T00:00:00',
            }
        parms.update(FmiApi.fixed_params)   # add the fixed parameters to the parameter list

        # perform the API request
        try:
            resp = requests.get(FmiApi.base_url, params=parms, stream=True)
        except:
            raise Exception('request failed')

        # check the request's status code for errors
        if resp.status_code != 200: raise Exception('FMI returned status code %d'%resp.status_code)

        # parse the raw XML data into an element tree object, exit on …
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Please ignore the last comment in the previous post, I misunderstood what the pest() function is actually doing.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

To elaborate on what I was saying earlier, I have tried running the code, and came up with problems. I was able to get the un-pickled list converted to a DataFrame as described above, but the next line:

    df_weath.sort_values('Date', inplace=True, ignore_index=True)

raises a KeyError exception:

Traceback (most recent call last):
  File "/home/schol-r-lea/Documents/Programming/Projects/Quick Tests/weather_pest.py", line 68, in <module>
    pest()
  File "/home/schol-r-lea/Documents/Programming/Projects/Quick Tests/weather_pest.py", line 14, in pest
    df_weath.sort_values('Date', inplace=True, ignore_index=True)
  File "/usr/lib/python3.9/site-packages/pandas/util/_decorators.py", line 311, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/pandas/core/frame.py", line 6259, in sort_values
    k = self._get_label_or_level_values(by, axis=axis)
  File "/usr/lib/python3.9/site-packages/pandas/core/generic.py", line 1779, in _get_label_or_level_values
    raise KeyError(key)
KeyError: 'Date'

I would expect that you would need to address this before proceeding with the actual projection.

EDIT: Looking at it again, I think the real problem is in how FmiApi is packing the data in the first place. It would be better to build a DataFrame from the start. I'll see what I can do to figure out what you can do, but I'll need to read up on Pandas before I can do that.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I'm afraid not, no.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I'm still stuck on handling the DataFrame you are reading in. As I understand it, pd.read_pickle() returns a list:

[{(64.93503, 25.3392): {'rrmon': ('31.2', '1960-01-01T00:00:00Z'),
                        'tmon': ('-11.6', '1960-01-01T00:00:00Z')}, 
  (65.03371, 25.47957): {'rrmon': ('50.6', '1960-01-01T00:00:00Z'),
                        'tmon': ('-11.7', '1960-01-01T00:00:00Z')}}, 
 {(64.93503, 25.3392): {'rrmon': ('15.4', '1960-02-01T00:00:00Z'),
                        'tmon': ('-12.3', '1960-02-01T00:00:00Z')},
  (65.03371, 25.47957): {'rrmon': ('17.3', '1960-02-01T00:00:00Z'),
                        'tmon': ('-11.9', '1960-02-01T00:00:00Z')}}, 
 ...
 {(65.01967, 24.72758): {'rrmon': ('41.3', '2020-12-01T00:00:00Z'),
                        'tmon': ('-1.5', '2020-12-01T00:00:00Z')},
  (64.93503, 25.3392): {'rrmon': ('NaN', '2020-12-01T00:00:00Z'),
                        'tmon': ('-1.7', '2020-12-01T00:00:00Z')},
  (64.68421, 25.08919): {'rrmon': ('43.9', '2020-12-01T00:00:00Z'),
                        'tmon': ('-1.6', '2020-12-01T00:00:00Z')},
  (65.0064, 25.39321): {'rrmon': ('NaN', '2020-12-01T00:00:00Z'),
                        'tmon': ('-1.5', '2020-12-01T00:00:00Z')},
  (64.93698, 25.37299): {'rrmon': ('51.6', '2020-12-01T00:00:00Z'),
                        'tmon': ('-2.0', '2020-12-01T00:00:00Z')}}]

This then needs to be converted to a DataFrame like so:

df_weath = pd.DataFrame(pd.read_pickle('wdata.pkl'))

However, when I do this, the resulting DataFrame does not actually have a column 'Date' (or 'date' - case is significant).

                                   (64.93503, 25.3392)  ...                               (64.68421, 25.08919)
0    {'rrmon': ('31.2', '1960-01-01T00:00:00Z'), 't...  ...                                                NaN
1    {'rrmon': ('15.4', '1960-02-01T00:00:00Z'), 't...  ...                                                NaN
2    {'rrmon': ('6.7', '1960-03-01T00:00:00Z'), 'tm...  ...                                                NaN
3    {'rrmon': ('22.5', '1960-04-01T00:00:00Z'), 't...  ...                                                NaN
4    {'rrmon': ('19.7', '1960-05-01T00:00:00Z'), 't...  ...                                                NaN
..                                                 ...  ...                                                ...
727  {'rrmon': ('NaN', '2020-08-01T00:00:00Z'), 'tm...  ...  {'rrmon': ('30.2', '2020-08-01T00:00:00Z'), 't...
728  {'rrmon': ('NaN', '2020-09-01T00:00:00Z'), 'tm...  ...  {'rrmon': ('94.9', '2020-09-01T00:00:00Z'), 't...
729  {'rrmon': ('NaN', '2020-10-01T00:00:00Z'), 'tm...  ...  {'rrmon': ('91.8', '2020-10-01T00:00:00Z'), 't...
730  {'rrmon': ('NaN', '2020-11-01T00:00:00Z'), 'tm...  ...  {'rrmon': ('86.8', '2020-11-01T00:00:00Z'), 't...
731  {'rrmon': ('NaN', '2020-12-01T00:00:00Z'), 'tm...  ...  {'rrmon': ('43.9', '2020-12-01T00:00:00Z'), 't...

[732 rows x 12 columns]

I'm not sure how you would re-label the columns so as to have an explicit 'Date' column.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Is the function pest() in a different source file, or the same one, and in either case, where does it get called?

I did copy the source code (into two separate files, since the FmiAPI only need to run once), and when running pest() I got the following error and traceback:

Traceback (most recent call last):
  File "/home/schol-r-lea/Documents/Programming/Projects/Quick Tests/weather_pest.py", line 66, in <module>
    pest()
  File "/home/schol-r-lea/Documents/Programming/Projects/Quick Tests/weather_pest.py", line 11, in pest
    df_weath = pd.read_csv('wdata.pkl', parse_dates=[0], infer_datetime_format=True)   
  File "/usr/lib/python3.9/site-packages/pandas/util/_decorators.py", line 311, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 586, in read_csv
    return _read(filepath_or_buffer, kwds)
  File "/usr/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 482, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
  File "/usr/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 811, in __init__
    self._engine = self._make_engine(self.engine)
  File "/usr/lib/python3.9/site-packages/pandas/io/parsers/readers.py", line 1040, in _make_engine
    return mapping[engine](self.f, **self.options)  # type: ignore[call-arg]
  File "/usr/lib/python3.9/site-packages/pandas/io/parsers/c_parser_wrapper.py", line 69, in __init__
    self._reader = parsers.TextReader(self.handles.handle, **kwds)
  File "pandas/_libs/parsers.pyx", line 542, in pandas._libs.parsers.TextReader.__cinit__
  File "pandas/_libs/parsers.pyx", line 642, in pandas._libs.parsers.TextReader._get_header
  File "pandas/_libs/parsers.pyx", line 843, in pandas._libs.parsers.TextReader._tokenize_rows
  File "pandas/_libs/parsers.pyx", line 1917, in pandas._libs.parsers.raise_parser_error
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte

This seems to indicate a problem in reading the pickled data file. Since you seem to be trying to read the pickled (binary) file as if it were a CSV text file, that's presumably the source of the problem. You presumably want to use pd.read_pickle() rather than pd.read_csv().

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

If you don't mind me asking, how are you running this? I am assuming that you are in a course on assembly language (or at the very least trying to learn from an old textbook), and that you are using DOSBox or something similar, but I am curious about the details. Note that INT 21H is specific to MS-DOS, and modern Windows doesn't support the old software interrupts at all.

As RProffitt said, you would want to read in the input as a pair of characters, then test both of them for their values to see if they are in the desired range.

I also agree on the point of the lack of comments. This is especially important in Assembly language (regardless of the ISA) given the lack of specificity in the individual instructions.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I am no expert on either PHP or MySQL, but I am fairly certain that that won't work, at least as you describe it. You would have to do a separate query to retrieve the value of receiptno for id = 1 first, then increment that value, then use the UPDATE query to set the new value - all while under a single transaction to prevent any hidden race conditions.

However, it also leads to the question of why you are updating the value of receiptno for an existing entry, or perhaps more cogently, why there is a separate receiptno (which is presumably an identifying value) and id (which is presumably a unique, non-data-driven primary key). If receiptno is UNIQUE, then having both is redundant, meaning that the table itself is poorly normalized.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I would recommend copying and pasting the code in the forum using the Code Block (</>) button, rather than posting a screen shot. I get that in this case you wanted to highlight what the editor was telling you, but even so, it is hard for us to work with the code if we only have an image of it.

I don't think it is the name button that is being flagged as invalid, but rather that you are attempting to access an element in a list that doesn't exist (either the list element, nor the list itself).

What you want to do is assign an empty list to button, then use the append method to add the elements to the list.

I'd also mention that, rather than creating list_1 and list_2 and populating them manually without actually using them, you could instead use the range() function. Note that list indices are zero-based, not one-based.

Putting this all together, it would look something like this:

class Buttons(App):
    def build(self):
        button = list()
        for i in range(6):
            elem = BoxLayout(orientation='horizontal'))
            for j in range(10):
                button.append(Button(text='{}{}'.format(elem, j))
                elem.addWidget(button[j])

I can't say for certain that this is what you want, but it seems closer to the intended effect than the original version. I don't know enough about Kivy to say if more needed to be done to make is work as desired. As things stand, it seems like it would create six BoxLayout widgets, populating each with ten Button widgets, but then …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

To speed things along, I'll save the OP the trouble of posting the code here:

#include <stdio.h>
int main()
{
  // Displaying menu for customers
  printf("\n%115s", "GEBU BAKERY SHOP");
  printf("\n%121s", "Bread Types and Pricing Detail\n");
  printf("\n%162s","____________________________________________________________________________________________________________\n");
  printf("%53s%30s%22s%22s%35s", "|", "|", "|", "|", "|");
  printf("\n%53s%15s%15s%15s%7s%15s%7s%26s%9s", "|", "Bread type", "|", "Unit price", "|", "Unit price", "|", " Filling price/unit", "|");
  printf("\n%53s%30s%17s%5s%16s%6s%35s", "|", "|", "(self collect)","|", "(Food Panda)", "|", "|");
  printf("\n%163s","|_____________________________|_____________________|_____________________|__________________________________|\n");
  printf("%53s%30s%22s%22s%35s", "|", "|", "|", "|", "|");
  printf("\n%53s%16s%14s%14s%8s%14s%8s%27s%8s", "|", "1) White Loaf", "|", " RM 5.00", "|", "RM 5.50", "|", "- RM 1.20 (Chocolate)", "|");
  printf("\n%127s%36s","|_____________________________|_____________________|_____________________|", "|\n");
  printf("%53s%30s%22s%22s%25s%10s", "|", "|", "|", "|", "- RM 1.50 (Coconut)", "|");
  printf("\n%53s%16s%14s%14s%8s%14s%8s%35s", "|", "2) Wheat Loaf", "|", " RM 5.50", "|","RM 6.00", "|", "|");
  printf("\n%127s%24s%12s","|_____________________________|_____________________|_____________________|", "- RM 1.00 (Pandan)", "|\n");
  printf("%53s%30s%22s%22s%35s", "|", "|", "|", "|", "|");
  printf("\n%53s%19s%11s%14s%8s%14s%8s%25s%10s", "|", "3) Bun + Filling", "|", "RM 2.00", "|", "RM 2.50", "|", "- RM 1.75 (Chicken)", "|");
  printf("\n%53s%30s%17s%5s%22s%35s", "|", "|", "(no filling)","|", "|", "|");
  printf("\n%127s%24s%12s","|_____________________________|_____________________|_____________________|", "- RM 1.00 (Butter)", "|\n");
  printf("%53s%30s%22s%22s%35s", "|", "|", "|", "|",  "|");
  printf("\n%53s%25s%5s%14s%8s%14s%8s%35s", "|", "4) Croissant + filling", "|", "RM 3.00", "|", "RM 3.50", "|", "|");
  printf("\n%53s%30s%17s%5s%22s%35s", "|", "|", "(no filling)","|", "|", "|");
  printf("\n%163s","|_____________________________|_____________________|_____________________|__________________________________|\n");

  printf("\n%156s", "Special Promotion!! : Free Ice cream when you purchase more than RM 50.00 (forself-collect only)\n");
  printf("\n%144s", "*Food Panda has a default delivery surcharge of RM5.00 for every order.*\n");

  //User-interface  
  int collect = 0;
  int bread;
  int breadnum;
  int breadtype[4]; //An array is used to store data and used in Order summary details
  int breadunit;
  char filling = 0;
  int fillingflavour = 0; …
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

If I might be blunt: what idiot taught you to use goto like that?

The goto statement and labels do have some legitimate uses. These are not those. It is an extremely bad idea to use goto indiscriminately like this.

If your instructor has taught an introductory class to use goto at all, you ought to report them to the school administration for incompetence and walk out of the course. Period, end of subject.

Having vented my spleen on this topic now, I would also mention:

  • The lack of decomposition into separate functions.
  • the naming of variables in the form name1, name2, ... nameN, rather than using an array.
rproffitt commented: Good choice of the word decomposition. Over time this code will decompose and smell bad. +16
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

We'd really need to see more of the code than you've posted, with the code for rendering and refreshing the window. As things stand, we don't even know what windowing toolkit you are using; I would assume that you are using the standard Tk library, but if so, we'd need to see when and how you are refreshing the display.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Which assembler are you using, and which specific platform (e.g., Raspberry Pi, Apple M1, etc.) is this to run on? While the use of the C library routines makes this generally less important, it is still relevant, as there are differences both in the syntax of specific ARM assemblers, and in how the assembly code interefaces with the library code.

macikayx13 commented: Raspberry PI +0
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Has the course (or any previous ones) discussed sorting algorithms, yet? Given the vagueness of the instructions, something very simple such as Bubble Sort or Gnome Sort should be sufficient, but I know that just saying that won't help much if you haven't studied those before.

As an aside, you would usually place a class into a separate source file, and use a header file to import the class declarations into the main program. If the instructor hasn't covered that topic yet, then it isn't a terribly important in such a straightforward program, but you will want to know about it ahead of time.

You generally also want to avoid using namespace std; in programs generally, but again, that's not really relevant in a homework problem like this - it is just something to keep in mind for the future.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

what does dest[i]=src[i] mean

(Note that I corrected your original, incorect line of dest[I] = to src[], which is syntactically wrong and semantically nonsense.)

It copies the current i element of the array pointed to by src to the equivalent location pointed to by dest.

There, that should be a technically correct yet entirely vacuous answer. Any other questions?

More seriously, to really answer the question, we'd have to know what you've been taught about how arrays, pointers, and array indices work in C. Any answer we give as things stand risk being either irritatingly vague, insultingly basic, or excessively advanced.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Dumping an assignment to a post without at least saying that is what you are doing isn't the most polite way to start a conversation, especially if you don't show any of your own effort to solve the problem.

It also isn't the safest approach, since plenty of professors regularly search the web to catch students doing things such as this (or more often, they get their TAs and grad students to do it for them).

There are websites where they will do your homework for you, at least for a fee. This isn't one of those sites.

So, try to solve it yourself, and if you get stuck, let us know what you've tried and we'll see if we can help you then. This may be difficult, given the rather minimal and poorly-specified assignment, but it is your assignment, not any of ours.

I will give you one hint, though, in that the problem is really aimed at demonstrating the use of fork(). The solution for the second part, emitting the list of primes, would be trivially solved using the algorithm known as the Sieve of Eratosthenes. Chances are, if you are in a course which covers fork() (usually a Systems Programming or Operating Systems course), then you should already be familiar with the Sieve from previous coursework.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

To elaborate on RProffitt's answer: the error message is saying that you are trying to read the whole array phy rather than a specific (indexed) element of phy. The error is saying that there is no defined cin>> operator for reading an entire array of int. Since this clearly isn't what you were trying to do, the answer RProffitt gave of iterating over the data arrays rather than an array of the marks structure illustrates what you need.

An alternative approach would be to have individual values in the marks struct, and iterate over an array of marks.

#include<iostream>
using namespace std;

struct marks{
    int phy;
    int math;
    int chem;
};

int main(){
    struct marks m[20];
    int i,n;
    cout<<"Enter the number of students : " << endl;
    cin >>n;
    for(i=0;i<n;i++){
        cout<<"\nEnter Physics marks: " << endl;
        cin >> m[i].phy;

        cout<<"\nEnter Maths marks : "<< endl;
        cin >> m[i].math;

        cout<<"\nEnter Chemistry marks : "<< endl;
        cin >> m[i].chem;
    }

    cout<<"\nStudents mark details : \n"<< endl;

    for(i=0;i<n;i++){
         cout<<"\nMarks of Student"<< i+1 <<" : "<< endl;
         cout<<"\nPhysics marks: "<< m[i].phy<< endl;
         cout<<"\nMaths marks: "<< m[i].math<< endl;
         cout<<"\nChemistry marks: "<< m[i].chem<< endl;
         cout<<"\n"<< endl;
    }
    return 0;
}

These two approaches are more or less equivalent; however, you appear to tried to do both at the same time, and got it mixed up as a result.

As a side note: why are you #includeing the conio.h header, a non-standard header which you aren't actually using, and which won't even work under most …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Dumping an assignment to a post without at least saying that is what you are doing isn't the most polite way to start a conversation, especially if you don't show any of your own effort to solve the problem.

It also isn't the safest approach, since plenty of professors regularly search the web to catch students doing things such as this (or more often, they get their TAs and grad students to do it for them).

There are websites where they will do your homework for you, at least for a fee. This isn't one of those sites.

So, try to solve it yourself, and if you get stuck, let us know what you've tried and we'll see if we can help you then. This may be difficult, given the rather minimal and poorly-specified assignment, but it is your assignment, not any of ours.

rproffitt commented: ++Good. +16
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Actually, I suspect that the opposite is the problem: the object was declared, but never initialized, and thus has a value of Nothing.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

One more possibility (of many) that comes to my mind is that the environment of the cloud server differs from that of the development system, and that there is either some subtle dependency which is lacking, or some added feature on the server which is blocking the script from functioning.

Do you know what sort of system the dev host is, and what sort of system the cloud server runs? If they are (for example) different versions of Windows, or different Linux distributions, that may account for the different behavior.

Similarly, assuming this is a RESTful or otherwise web-based application (which it sounds as if it is), are they using different HTTPS servers for the testing and production servers (e.g., Apache vs. Nginx vs. IIS)? Are there any specific server configs required by the script which the developer neglected to mention, or which you (or the cloud server admin, if that's someone else) may have overlooked?

Also, assuming this is querying a database, how does the test database compare to the production database?

How is the script being tested on the dev host? Is the developer certain that it is being run through the HTTPS server, and not as a purely local script somehow?

Is the script primarily client-side or server-side, or are there separate components for each?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I did notice that editing the URL only set it to "about:blank", but that doesn't seem to be what you actually were referring to.

razstec commented: i can only get it to open in a new window. my issue is how to make it open in a frame in order to insert it in the interface +3
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I'm sure there's a way to do it, but I've been otherwise occupied and haven't had a chance to address the question. Sorry.

I did test it, and it seems to work well enough, if not exactly the most sophisticated - I tried using Google search's "I'm Feeling Lucky" and it let me select a page to load. I'm not sure what the problem you are having is; does it have to do with the links to other websites? I never get the list of websites, it just goes to Google.