Invalid preprocessing directive #using

Keep getting this error even though I have tried to trouble shoot multiple ways.

error: invalid preprocessing directive #using #using <system.dll> ^~~~~ exit status 1 invalid preprocessing directive #using

My code is in text and linked:

// C++ code
//
#using <system.dll>
using namespace System;
using namespace System::Diagnostics;
void setup() {
pinMode(A2, INPUT);
pinMode(A0, INPUT);
}
void loop() {
while (analogRead(A2) != 0) {
String *sSource;
String *sLog;
String *sEvent;
String *sData
sSource = new String("shest");
sLog = new String("Test");
sEvent = new String("Crash button pressed");
sData = new String(analogRead(A0))
if (!EventLog::SourceExists(sSource)) EventLog::CreateEventSource(sSource, sLog);
EventLog::WriteEntry(sSource, sEvent);
EventLog::WriteEntry(sSource, sEvent, EventLogEntryType::Alert, 235);
}
}
}

glorious_rottis1-2.ino (647 Bytes)

did you mean

#include <system.dll>

No, I followed the guide here to log:

https://docs.microsoft.com/en-us/troubleshoot/cpp/write-entry-to-event-log

arduino using GNU C/C++ not Microsoft Visual C++

and system.dll does sound very very windows like... dynamically linked library ??

I didn't know there was a difference. That on me lol. I'm new to this so I'll take all the help I can get.

So would a like .txt file work or something?

do you mean writing to a file?

can you explain what you're trying to do?

what's this System library ??? what's the EventLog class?
do yo have a link to it for Arduino ?

if you want to write to an SD card, use the SD or SDfat library for example

I want to log Analog pin A0 to a text file pretty much

So that it can be downloaded and you can see the info

do you just want to see the value of one analog input when a different analog input is not zero?

void loop() {
    if (analogRead(A2) != 0) {
        Serial.println ( analogRead(A0);
}

Yeah, pretty much. This is kinda what I want to happen.

When button pressed (A3), get data from ultrasonic sensor (A0) from the last 10 seconds and log values from US and time.

I already have the hardware, I just need the software.

Sorry if its too complex, I have complex ideas sometimes

it's easy. It's just unclear where you want the data to be.

Your arduino cannot write anything on your PC hard drive directly (would be quite a security hole !!!) so you need to decide where the data will go.
it could go on the serial line to the Serial monitor and then it's saved as a file, or it could be saved on an SD card on your Arduino if you have one connected... it could be sent by Wi-Fi or ethernet or bluetooth or SMS ... all depends on what you want to do and what hardware is available with your arduino

can't a terminal emulator like putty capture it's input in a file?

Yes, but it's not directly.
You need a programm running on the PC, listening to the Serial port and writing to the HD

Yeah just so it can be downloaded in a way. It's for a future product so the consumer has to be able to download it somehow. A file such as .txt would work. What are the options for an Arduino Uno?

putty?

maybe you don't realize that the arduino interface to the PC is simply a serial interface and any program (e.g. putty) that can connect to a serial interface can communicate with an arduino instead of using the serial monitor

@gcjr

I am not sure what you are saying.

I said

Your arduino cannot write anything on your PC hard drive directly

notice the directly ?

So whatever program reading the Serial Port is an indirect way.

The Arduino does not see nor write to the hard drive. Your "whatever program" (e.g. putty) is what will have authorisation to write to the disk.