/r/CodingHelp

Photograph via //r/CodingHelp

Welcome! Feel free to ask any questions regarding coding you have!

Our Rules

1. FLAIR YOUR POSTS! Don't put tags in post titles!

2. Do not ask us to do all the coding for you unless you have money to spend. (If you have got money to spend, make that clear and the amount in question).

3. Do not post spam and/or misleading titles.

4. Do not be abusive to other coders.

5. Please format code properly, or use a site such as Gist or Pastebin. If possible please provide a live example of your issue.

6. Do not downvote people because you think they asked a dumb question. Just because you think that someone has a dumb question, doesn't mean that it is dumb to them.

7. Do not have a misleading user flair. Keep them sensible, describing your level of coding ability and/or languages you know and/or your profession.

8. Please do not ask unethical questions, such as asking for homework to be written by someone else, or asking someone to copy another project directly.

9. Make sure to follow the Reddit Rules.


How to start coding:

Check our website https://codinghelp.site we have all the information you need there!


Related subreddits:


Suggest a post flair

If you have any suggestions for flairs (programming languages or generic coding topics) that we should add, please use the button below to message the mods with your suggestion.

If approved as a sensible flair for the community to use, it will be added to our bot for automated suggestions and to the flair list for everyone to use!

Anyone who abuses this by spamming mods will be banned.


Current supported flairs

  • HTML
  • CSS
  • Javascript
  • PHP
  • SQL
  • Ruby
  • Java
  • Python
  • C++
  • C#
  • C (Not in Bot)
  • Open Source
  • Other Code
  • Random
  • Meta

Flair colors

  • Green

Web Related Languages (Eg HTML, CSS)

 

  • Blue

App Related Languages (Eg Python, C#)

 

  • Red

Generic Coding Topics (Eg Open Source)

 

  • Yellow

Other Flairs (Eg Random, Meta)


/r/CodingHelp

81,171 Subscribers

2

Beginners dilemma

Hello everyone, as a beginer in the world of coding Im curious where and how I should start my journey?
I mean, I have basically 0 understanding of what to do.
Im thinking of learning Python as my first language.
Appreciate any advices

4 Comments
2024/12/12
18:46 UTC

1

Help with PHP code

I'm trying to create a code for a fee for something, but I'm not a coder so I'm going by Google and whatever other info I can find. I can't say what's it for, but I was wondering if the general logic of it was okay? Sorry I have no clue how to do this shit.

I guess if would work like this. I do know the names for the things in the quotation marks, I just don't feel comfy putting them.

Type="the thing it needs to put a fee on" {

"If the thing used one of these"="is one of these two things separated by comma" => 0 # there is no fee at all, it's 0.

Otherwise fees are as follows

"If the thing used one of these these"="list of these separated by comma" => then it gets a fee of amount XYZ # (ABC + DEF)

=> Otherwise the fee is just ABC amount

}

Does that make sense, kinda? I know this is stupid I'm so sorry, I don't code.

1 Comment
2024/12/12
17:32 UTC

0

install invalid

>>> pip install colorama

File "<python-input-0>", line 1

pip install colorama

^^^^^^^

SyntaxError: invalid syntax

>>>

3 Comments
2024/12/12
16:46 UTC

2

Please I need help to gain access to the MIMIC 4 or eICU Collaborative Research Database ASAP

I have requested the access from physionet, but i need the databases ASAP. Like it is very important for a research paper i am doing. I need to run some tests on different datasets!! Please send me this if you have!! Please PLeaasee please

0 Comments
2024/12/12
14:37 UTC

1

Help to solve this exercise

Efficient Container Stacking Algorithm - Practice Problem

I'm working on a problem related to algorithm design and would appreciate any help or suggestions. Here’s the scenario:

In a commercial port, goods are transported in containers. When unloading a ship at the terminal, it's crucial to use the smallest possible surface area. To achieve this, the containers need to be stacked optimally.

We have N containers (numbered from 1 to N), all with the same dimensions. For each container, we are given:

  1. Its weight.
  2. Its maximum load capacity (i.e., the total weight it can support on top of it).

The goal is to stack as many containers as possible in a single pile while respecting these constraints:

  1. A container can only be placed directly on top of another.
  2. A container cannot be placed on top of another with a larger serial number.
  3. The total weight of all containers placed on top of a container cannot exceed that container’s maximum load capacity.

Input Format

  • The number of containers, N (1 ≤ N ≤ 800).
  • For each container, two integers: its weight (wᵢ ≤ 5000) and its maximum load capacity (cᵢ ≤ 5000).

Output Format

  • The maximum number of containers that can be stacked.
  • The serial numbers of the containers in ascending order that form the pile.

Example

Input:

21  
168 157  
156 419  
182 79  
67 307  
8 389  
55 271  
95 251  
72 235  
190 366  
127 286  
28 242  
3 197  
27 321  
31 160  
199 87  
102 335  
12 209  
122 118  
58 308  
5 43  
3 84  

Output:

Number of containers: 13  
Container 2  
Container 4  
Container 5  
Container 6  
Container 8  
Container 11  
Container 12  
Container 13  
Container 14  
Container 17  
Container 19  
Container 20  
Container 21  

Question

What is the most efficient algorithm to solve this problem for values of N up to 800? Any advice or suggestions would be greatly appreciated!

0 Comments
2024/12/12
12:44 UTC

5

Where can I find people to pay to code me a website?

OK so basically I have no knowledge of coding nor do I have the time or interest in learning it.

I've tried looking on freelancing websites like fivver but tjose are overrun with AI chatbot that make communication impossible because they mess up everything you say or just don't forget what you said after two messages.

Money isn't an issue, I just need to find an actual real human person who can code me a website to my liking.

8 Comments
2024/12/12
11:54 UTC

3

FNF Psych engine doesn’t want to compile

So I’ve been trying to compile the source code for Psych engine ver 1.0 but it doesn’t start with compiling but instead gives me this: source/backend/ui/PsychUIInputText.hx:224: characters 3-9 : expected }

And I dunno how to fix this since I’m really mediocre at coding still… Can anyone help me with this?

2 Comments
2024/12/12
10:37 UTC

1

"Unhandled exception at 0x004018EF in Project.exe: 0xC0000094: Integer division by zero." in assembly.

Hello, I'm doing assembly in Visual Studio for class and got started on a recent problem where I have to make an array fill with 50 random numbers with value between two numbers. I just started writing the code and I got the error quoted in this title, which was very confusing to me because I don't see where I could of divided by zero? Here's the code, I get the error when I call FillRandom:

.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword

WaitMsg proto
Clrscr proto
Gotoxy proto
WriteChar proto
ReadInt proto
WriteDec proto
Randomize proto
RandomRange proto


.data
intArray sdword 50 DUP(?)
count DWORD 0

.code
main proc
call Randomize
mov esi, OFFSET intArray
mov ecx, LENGTHOF intArray
mov ebx, 10
mov eax, 20
call FillRandom
mov ebx, 5
mov eax, 50
call FillRandom




invoke ExitProcess,0
main endp

FillRandom proc

L1:
sub eax, ebx
call RandomRange
add eax, ebx
mov [esi], eax
add esi, 4
loop L1
ret
FillRandom endp

end main
7 Comments
2024/12/12
06:04 UTC

1

Help making a loading bar on a canvas in tkinter

I'm trying to make a loading bar, it's totally not necessary but it really shouldn't be this hard to do. Here is my code:

def LoadingAnimation():

desktopBackground.delete("all")

desktopBackground.create_polygon(230,400,

230,500,

200,500,

200,400,

fill="",

outline="black",

)

loadingBar = desktopBackground.create_polygon(230,400,

230,400,

200,400,

200,400,

fill = "green2")

loadingBarPosition = desktopBackground.coords(loadingBar)

for i in range(0,100):

WINDOW.update()

time.sleep(0.02)

desktopBackground.delete(loadingBar)

I can't get the for loop at the end to update the coordinates of the bar each time, is there an easy way to do this? I've looked online and found some things but nothing that I could use. Any help would be appreciated. Thanks!

2 Comments
2024/12/12
00:53 UTC

0

Help fix my code please

when i go to hit the good and bad buttons, it sends the information to the first entered info. if i submit Billy and Susie, and try to do susie first. it sends it to billy instead. i dont know how to fix this. and yes i used AI to make this code cause i barely know anything lol

<html><head><title>######## Battery Charge Alert</title><link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet"><style> body { padding: 20px; } .loading { display: none; } </style></head><body><div class="container"><h1 class="mb-4">######## Battery Charge Alert</h1><form id="customerForm"><div class="mb-3">

<label for="customerName" class="form-label">Customer Name</label>

<input type="text" class="form-control" id="customerName" required placeholder="Field Required"></div><div class="mb-3">

<label for="ticketNumber" class="form-label">Ticket Number</label>

<input type="text" class="form-control" id="ticketNumber" required placeholder="Field Required"></div><div class="mb-3">

<label for="customerPhone" class="form-label">Phone Number</label>

<input type="tel" class="form-control" id="customerPhone" required placeholder="Field Required"></div>

<button type="submit" class="btn btn-primary">Add Customer</button>

</form></div><div class="container mt-5"><h2>Lookup Customer</h2><input type="text" class="form-control mb-3" id="searchInput" placeholder="Enter Name or Ticket Number">

<button class="btn btn-secondary" onclick="searchCustomer()">Search</button>

<div id="searchResults" class="mt-4"></div><div class="loading mt-3" id="loadingIndicator"><div class="spinner-border text-primary" role="status">

<span class="visually-hidden">Loading...</span>

</div></div></div><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.min.js"></script><script> const customers = \[\]; document.getElementById('customerForm').addEventListener('submit', function(e) { e.preventDefault(); const name = document.getElementById('customerName').value; const ticket = document.getElementById('ticketNumber').value; const phone = document.getElementById('customerPhone').value; customers.push({ name, ticket, phone }); this.reset(); alert('Customer added successfully!'); }); function searchCustomer() { const searchInput = document.getElementById('searchInput').value.toLowerCase(); const results = customers.filter(customer => customer.name.toLowerCase().includes(searchInput) || customer.ticket.toLowerCase().includes(searchInput) ); const searchResults = document.getElementById('searchResults'); searchResults.innerHTML = ''; if (results.length > 0) { results.forEach((customer, index) => { searchResults.innerHTML += \` <div class="card mb-3"> <div class="card-body"> <h5 class="card-title">${customer.name}</h5> <p class="card-text">Ticket Number: ${customer.ticket}</p> <p class="card-text">Phone: ${customer.phone}</p> <button class="btn btn-success" onclick="prepareSMS(${index}, 'good')">Good</button> <button class="btn btn-danger" onclick="prepareSMS(${index}, 'bad')">Bad</button> </div> </div> \`; }); } else { searchResults.innerHTML = '<p>No customers found.</p>'; } } function prepareSMS(index, status) { const customer = customers\[index\]; const message = \`Hello ${customer.name}, your battery is ready to be picked up at ###########. The battery tested ${status}. Please pick it up within 48 hours. Thank you.\`; document.getElementById('loadingIndicator').style.display = 'block'; // Simulating an AJAX call setTimeout(() => { alert(\`SMS sent to ${customer.phone}: ${message}\`); customers.splice(index, 1); searchCustomer(); document.getElementById('loadingIndicator').style.display = 'none'; }, 2000); } </script></body></html>
4 Comments
2024/12/12
00:41 UTC

5

Coding cake feedback

Hi everyone! I’m not sure if this is the best place to post this, if not please direct me elsewhere!

So my fiancé showed me a coding themed cake that he thought was cool a few months ago. His birthday is coming up and I would like to have it made for him. I can’t find a picture of the exact cake and I have no experience with coding lol.

https://pin.it/66OhIlzLU

This is what I found from looking online. I want it to say some variation of “Happy 25th birthday (name)! I love you!” Would the cake in the link above be fine or is there a better way to format it?

Thank you!

2 Comments
2024/12/11
21:52 UTC

1

Help data scraping for TFT use

Hi, I'm having trouble scraping character stats for a game called Teamfight Tactics. I don't currently have a Riot API to use, therefore am basing my data off TFTactics.gg. Below is currently what I have but it doesn't seem to work, any suggestions?

const axios = require('axios');
const cheerio = require('cheerio');
const fs = require('fs');

// URL of the TFT website with champion data
const URL = "https://tftactics.gg/tierlist/champions/";

async function scrapeTFTChampions() {
  try {
    // Fetch the HTML of the webpage
    const { data } = await axios.get(URL);
    const $ = cheerio.load(data);

    const champions = [];

    // Adjust the selectors to match the website structure
    $('.tierlist-row .tierlist-card').each((index, element) => {
      const name = $(element).find('.card-name').text().trim(); // Extract champion name
      const tier = $(element).find('.tier-indicator').text().trim(); // Extract tier

      // Extract traits
      const traits = $(element)
        .find('.card-traits span')
        .map((i, el) => $(el).text().trim())
        .get();

      // Extract stats from .character-stats and .stats-list
      const stats = {};
      $(element)
        .find('.character-stats .stats-list li')
        .each((i, statElement) => {
          const statName = $(statElement).find('span.bold').text().replace(':', '').trim();
          const statValue = $(statElement).contents().last().text().trim(); // Text after <span>
          stats[statName] = statValue;
        });

      // Handle character-items (if necessary in the future)
      const items = $(element)
        .find('.character-items img')
        .map((i, el) => $(el).attr('alt')) // Extract item names from alt attributes
        .get();

      // Build the champion object
      const champion = {
        name,
        tier: parseInt(tier, 10),
        traits,
        stats,
        items, // Include items if needed
      };

      champions.push(champion);
    });

    // Save the data to a JSON file
    fs.writeFileSync('champions.json', JSON.stringify(champions, null, 2));
    console.log('Champion data saved to champions.json');
  } catch (error) {
    console.error('Error fetching champion data:', error);
  }
}

scrapeTFTChampions();
2 Comments
2024/12/11
12:34 UTC

0

HELP ASAP PLEASEE. DESPERATE 😭

I don't know much about this stuff but I have been trying and I'm extremely eager to learn now and have this knowledge for better purposes than this unfortunately I really need some help figuring out some codes if anyone could help please!!!!!

4 Comments
2024/12/11
11:19 UTC

1

Decoding an image in MATLAB, but getting a repeating image

Hi guys, I'm currently finishing up a project that uses 64-QAM modulation and matched filtering to decode a noisy signal and display an image. The problem I'm having is I can display an image, but it's a repeating grid of the image in a very low quality that gets more noisy as it goes down the grid. I can't figure out why it's doing this, if anyone might be able to figure it out. I should note there's an external file containing a vector with the noisy QAM constellation as well as the "map" function there as well. The doc I attached is a screenshot of the image and the other link is the code. Thanks so much

https://docs.google.com/document/d/15co1CxllHsm6LHj2GBtpn-R_jRR4Kk25eqEpamhoG7c/edit?usp=sharing

https://pastebin.com/15W1YLqt

0 Comments
2024/12/11
05:51 UTC

1

Can someone help me fix my functions?

0 Comments
2024/12/11
05:17 UTC

1

pom.xml unresolved dependency error with AWS SDK in Maven

I'm encountering a strange issue with Maven in my Java project, and I’m hoping someone can help. I'm using the AWS SDK, specifically the software.amazon.awssdk:core dependency, version 2.29.29. When I run mvn dependency:tree, all dependencies resolve correctly, and I get a BUILD SUCCESS. However, when I try running mvn clean install, Maven throws an unresolved dependency error for software.amazon.awssdk:core:jar:2.29.29. I've tried clearing the Maven cache for AWS SDK, then forced Maven to redownload the dependencies... I checked the dependency tree and it showed no conflictions. Despite my efforts, I still get a unresolved dependency error for software.amazon.awssdk:core:jar:2.29.29.

This is the error I continue to get:

Unresolved dependency: 'software.amazon.awssdk:core:jar:2.29.29'

Here is what my pom file looks like:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.vetclinic</groupId>
    <artifactId>vet-clinic-application</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>software.amazon.awssdk</groupId>
                <artifactId>core</artifactId>
                <version>2.29.29</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <!-- AWS SDK Dependencies with Explicit Versions -->
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>core</artifactId>
            <version>2.29.29</version>
        </dependency>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>rds</artifactId>
            <version>2.29.29</version>
        </dependency>
        <dependency>
            <groupId>software.amazon.awssdk</groupId>
            <artifactId>s3</artifactId>
            <version>2.29.29</version>
        </dependency>
        <!-- MySQL Connector -->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.33</version>
        </dependency>
        <!-- JavaFX Modules -->
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>20</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>20</version>
        </dependency>
        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>2.0.9</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>2.0.9</version>
        </dependency>
    </dependencies>
    <repositories>
        <!-- Ensure Maven Central Repository -->
        <repository>
            <id>central</id>
            <url>https://repo.maven.apache.org/maven2/</url>
        </repository>
    </repositories>
    <build>
        <plugins>
            <!-- Maven Compiler Plugin -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
0 Comments
2024/12/11
01:15 UTC

0

Where do you keep or post what you code?

I used tumblr's custom pages years ago for coding. Unfortunately, it doesn't work on a tablet. I've been unable to find a free alternative ever since, especially one that will work on my tablet.

I have an idea of what I want to do, but I only have basic HTML/CSS knowledge. I could get so much further if I could just find a site to practice on that isn't solely a "learning" site where you can't actually share/view what you've made, and you're limited to their tutorial pages.


I'm also not sure where to say this as it's a bit unrelated to my post, but the pinned post/FAQ here says that you can learn to code on a tablet, then immediately contradicts itself...

"All you need to do ... is to read about coding and try writing it down on a piece of paper. Then when you have a chance to reach a computer, you can code that and test your code"...

It flat out is saying you need a computer to test your code, which is a major part of learning. Frankly, either you can or can't learn to code on a tablet, and that line flip-flops between the two. I don't understand why this is in the FAQ if there isn't a straightforward answer for the writer to settle on.

5 Comments
2024/12/10
21:09 UTC

1

Writing data to an S7 PLC from an arduino

Hey folks,

i am working on writing and reading data to an S7 PLC (315 2-DP) from an arduino over profinet/ethernet.

I choose the settimino library for this https://settimino.sourceforge.net

It worked quite out of the box as long as i read data. Like DB, M ect.

But writing is a whole different story. There is also no example about writing data back to the plc.

/*----------------------------------------------------------------------
Data Read Demo

 Created  12 Dec 2016
 Modified 10 Mar 2019 for Settimino 2.0.0
 by Davide Nardella
 
------------------------------------------------------------------------
This demo shows how to read data from the PLC.
A DB with at least 1024 byte into the PLC is needed.
Specify its number into DBNum variable

- Both small and large data transfer are performed (see DO_IT_SMALL)
- During the loop, try to disconnect the ethernet cable.
  The system will report the error and will reconnect automatically
  when you re-plug the cable.
- For safety, this demo *doesn't write* data into the PLC, try
  yourself to change ReadArea with WriteArea.
- This demo uses ConnectTo() with Rack=0 and Slot=2 (S7300)
  - If you want to connect to S71200/S71500 change them to Rack=0, Slot=0.
  - If you want to connect to S7400 see your hardware configuration.
  - If you want to work with a LOGO 0BA7 or S7200 please refer to the
    documentation and change 
    Client.ConnectTo(<IP>, <Rack>, <Slot>);
    with the couple
    Client.SetConnectionParams(<IP>, <LocalTSAP>, <Remote TSAP>);
    Client.Connect();
    
----------------------------------------------------------------------*/
#include "Platform.h"
#include "Settimino.h"

// Uncomment next line to perform small and fast data access
#define DO_IT_SMALL

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 
  0x90, 0xA2, 0xDA, 0x0F, 0x08, 0xE1 };

IPAddress Local(192,168,0,90); // Local Address
IPAddress PLC(192,168,0,12);   // PLC Address

// Following constants are needed if you are connecting via WIFI
// The ssid is the name of my WIFI network (the password obviously is wrong)
char ssid[] = "SKYNET-AIR";    // Your network SSID (name)
char pass[] = "yourpassword";  // Your network password (if any)
IPAddress Gateway(192, 168, 0, 1);
IPAddress Subnet(255, 255, 255, 0);

int DBNum = 100; // This DB must be present in your PLC
byte Buffer[1024];

S7Client Client;

unsigned long Elapsed; // To calc the execution time
//----------------------------------------------------------------------
// Setup : Init Ethernet and Serial port
//----------------------------------------------------------------------
void setup() {
    // Open serial communications and wait for port to open:
    Serial.begin(115200);
    
#ifdef S7WIFI
//--------------------------------------------- ESP8266 Initialization    
    Serial.println();
    Serial.print("Connecting to ");
    Serial.println(ssid);
    WiFi.begin(ssid, pass);
    WiFi.config(Local, Gateway, Subnet);
    while (WiFi.status() != WL_CONNECTED) 
    {
        delay(500);
        Serial.print(".");
    }
    Serial.println("");
    Serial.println("WiFi connected");  
    Serial.print("Local IP address : ");
    Serial.println(WiFi.localIP());
#else
//--------------------------------Wired Ethernet Shield Initialization    
    // Start the Ethernet Library
    EthernetInit(mac, Local);
    // Setup Time, someone said me to leave 2000 because some 
    // rubbish compatible boards are a bit deaf.
    delay(2000); 
    Serial.println("");
    Serial.println("Cable connected");  
    Serial.print("Local IP address : ");
    Serial.println(Ethernet.localIP());
#endif   
}
//----------------------------------------------------------------------
// Connects to the PLC
//----------------------------------------------------------------------
bool Connect()
{
    int Result=Client.ConnectTo(PLC, 
                                  0,  // Rack (see the doc.)
                                  2); // Slot (see the doc.)
    Serial.print("Connecting to ");Serial.println(PLC);  
    if (Result==0) 
    {
      Serial.print("Connected ! PDU Length = ");Serial.println(Client.GetPDULength());
    }
    else
      Serial.println("Connection error");
    return Result==0;
}
//----------------------------------------------------------------------
// Dumps a buffer (a very rough routine)
//----------------------------------------------------------------------
void Dump(void *Buffer, int Length)
{
  int i, cnt=0;
  pbyte buf;
  
  if (Buffer!=NULL)
    buf = pbyte(Buffer);
  else  
    buf = pbyte(&PDU.DATA[0]);

  Serial.print("[ Dumping ");Serial.print(Length);
  Serial.println(" bytes ]===========================");
  for (i=0; i<Length; i++)
  {
    cnt++;
    if (buf[i]<0x10)
      Serial.print("0");
    Serial.print(buf[i], HEX);
    Serial.print(" ");
    if (cnt==16)
    {
      cnt=0;
      Serial.println();
    }
  }  
  Serial.println("===============================================");
}
//----------------------------------------------------------------------
// Prints the Error number
//----------------------------------------------------------------------
void CheckError(int ErrNo)
{
  Serial.print("Error No. 0x");
  Serial.println(ErrNo, HEX);
  
  // Checks if it's a Severe Error => we need to disconnect
  if (ErrNo & 0x00FF)
  {
    Serial.println("SEVERE ERROR, disconnecting.");
    Client.Disconnect(); 
  }
}
//----------------------------------------------------------------------
// Profiling routines
//----------------------------------------------------------------------
void MarkTime()
{
  Elapsed=millis();
}
//----------------------------------------------------------------------
void ShowTime()
{
  // Calcs the time
  Elapsed=millis()-Elapsed;
  Serial.print("Job time (ms) : ");
  Serial.println(Elapsed);   
}
//----------------------------------------------------------------------
// Main Loop
//----------------------------------------------------------------------
void loop() 
{
  int Size, Result;
  void *Target;
   
#ifdef DO_IT_SMALL
  Size=64;
  Target = NULL; // Uses the internal Buffer (PDU.DATA[])
#else
  Size=1024;
  Target = &Buffer; // Uses a larger buffer
#endif
  
  // Connection
  while (!Client.Connected)
  {
    if (!Connect())
      delay(500);
  }
  
  Serial.print("Reading ");Serial.print(Size);Serial.print(" bytes from DB");Serial.println(DBNum);
  // Get the current tick
  MarkTime();
  Result=Client.ReadArea(S7AreaDB, // We are requesting DB access
                         DBNum,    // DB Number
                         0,        // Start from byte N.0
                         Size,     // We need "Size" bytes
                         Target);  // Put them into our target (Buffer or PDU)
  if (Result==0)
  {
    ShowTime();
    Dump(Target, Size);
  }
  else
    CheckError(Result);
    
  delay(500);  
}

This is the example project. If i change ReadArea to WriteArea the expected happens: The DB (in this case DB100) gets set to 0 because the Target is empty.

So i just have to construct a message. And now there is my problem: Target is void. But it is referenced (void *Target; ) . I didnt even know it was possible to reference a void?

Same thing here: void Dump(void *Buffer, int Length)

Buffer is the same thing.

Did someone work with this library and wrote data to the PLC or can tell me how to construct a message?

Usally i figure it out at one point but this is just over me.

Any help would be appreciated!

0 Comments
2024/12/10
19:33 UTC

0

this is for pygame

so you know how you got a title and it appears on screen. how can i move the text so it looks centered, right now its horrible.

def message():
    font = pygame.font.SysFont("cambria", 25)
    img = font.render("An evil wizard as transformed\nyou into a sword\nuse that against him!", True, (255, 255, 255))
    img.set_alpha(alpha)
    screen.blit(img, (250, 0))

i cant get the text to center after the \n parts
4 Comments
2024/12/10
18:53 UTC

0

Integrating tch-rust with docker

Trying to run my rust app that uses tch-rs (version 0.18.0) in a docker container. Spent 30+ hours working on it and I feel like I've tried just about everything and still haven't gotten tch-rs to build properly. If anyone has ever succeeded in doing this, I need to know exactly what to put in my cargo.toml, build.rs and dockerfile. Doesn't have to be pretty i just need the library to build properly.

1 Comment
2024/12/10
17:37 UTC

1

Help with finding specific audio in webinar

Hey! I’m required to take online learning courses; these courses are generally a few hours long. At certain points in the pre recorded webinars the admins will sneak in a an audio code like “ur code is 12345” and then the webinar will continue, and at the end of the webinar I’ll be required to enter the three of four codes as a certification of completion. I’ve heard people will hack and view the audio data to easily find out at what point these audio codes r snuck in, fast fwd to those points and listen to said codes. Was hoping someone can instruct me on how this can b done. Any help is appreciated!

4 Comments
2024/12/10
16:22 UTC

0

How much time?

How much time should i take on learning C programing from scratch like 0 prev coding knowledge, pls be honest…

8 Comments
2024/12/10
13:23 UTC

0

Why does this not work??

This code is supposed to produce a students name and result but instead produces a -1 and unkown any help. My tutor told me its a logic error but idk what im lookin at.

def highResult(): loopCounter = 1 highScore = -1 highplayer = “unkown” while loopCounter < 22: if students[loopCounter] < highScore: highScore = students[loopCounter] highplayer = students[loopCounter - 1] loopCounter = loopCounter + 2 print(“The highest score was”, highScore, “by”, highplayer)

5 Comments
2024/12/10
11:55 UTC

1

Can someone please help me resolve an issue

I am trying to automate testing for a website. I have set configurations for executing in local chrome driver in a json file and use that file for -DdriverConfig while executing. I am getting an issue, while the browser is launching it is showing who’s using chrome on startup page which is causing the whole test to fail. I have tried mentioning user-data-dir and profile-directory in chromeOptions but it is not resolving my issue. Can someone help!

8 Comments
2024/12/10
11:45 UTC

1

NX build file structure

Hello, I'm apologizing in advance because this post is probably going to lack in details as I am still pretty unfamiliar with this technology. I am working on an app that was built using the ng command at first, we are switching to a monorepo and now use the nx command. The generated file structure is different, for instance many files (like index.html) are put at /path/myapp/browser/index.html instead of /path/myapp/index.html. It causes the browser not to find it anymore.

We tried to manually move everything from the browser folder to the root of the app, it is better but doesn't resolve everything. We also tried adding "--base-href=/myapp/browser/" to the build command but it also didn't solve everything.

What's the simplest way to have my app work with the nx structure? Do I need to change my config files, my tomcat configuration, all of that (if possible, I'd like all types of app to still be working, that's why I'm not so sure about changing the tomcat)? Also please tell me if this isn't the best sub to ask. Thanks!

0 Comments
2024/12/10
10:05 UTC

7

Which language would you say is the easiest to learn & execute?

I honestly would love to see them ranked from easiest to hardest but curious to know which do you all collectively agree on as the easiest language out there.

9 Comments
2024/12/10
02:22 UTC

0

Looking for coding buddies

Anyone wanna code with me discord: staarmaster23

3 Comments
2024/12/10
00:30 UTC

1

Best Reddit or discord servers to find people to collab with on projects

I'm looking for ways to find teams to code with for fun weather it be a Reddit channel or discord servers please help me

1 Comment
2024/12/10
00:27 UTC

0

I was wondering if anyone could help me with my coding?

I am in the process of creating a website is fine except for the javascript portion. I am not too familiar with JS, and the JS that I did implement is not translating over when I try to see if the events I have added are working. My TA said I should try debugging, but I am also not familiar with how to debug onvscode edu as well as on a browser, so if possible, would anyone be willing to look over my code and identify where I went wrong as well as give tips on how to debug in the future so I can navigate issues more easier? The two issues with my website is that my form sign now button is now working alongside my toggleModal feature either displays or does not display and the close botton on that is also not working. Here is my code if you are able to help, thank you; https://vscodeedu.com/iUxbzAhW5yObP258yq3F

3 Comments
2024/12/09
20:51 UTC

2

Question from someone who is not fluent in Python

I am a tutor at a community college and I have general coding knowledge. I had a student give me this code and I was wondering how line 10 worked the way it does. Usually for something like that I would have done a full for loop set up. Also to give further context, the file is essentially meant to turn a phrase into piglatin, meaning all words have to start with a vowel and end in "ay". The student wanted me to check the work and need help with where to create a loop when I pointed out that it wouldn't work with words that start with two or more consonants.

  1. def pseudo(word):
  2. vowels = "aeiouAEIOU"
  3. if word[0] in vowels:
  4. return word + "ay"
  5. else:
  6. return word[1:] + word[0] + "ay"
  7.  
  8. def main():
  9. input_words = input("Enter statement/word: ").split()
  10. translated_words = [pseudo(word) for word in input_words]
  11. print(" ".join(translated_words))
  12.  
  13. if __name__ == "__main__":
  14. main()
6 Comments
2024/12/09
18:41 UTC

Back To Top