How Can We Help?
Scrolling of different text messages according to the state of their associated bit
Here we see how to display different messages (strings in LWx) one after the other in the bottom field according to the state of their respective bit LBx
So the “green” messages will be displayed one after the other in a loop in the last field LW50100

This gives us
- 4 “ASCII Entry” fields in LW50000, LW50010, LW50020 and LW50030
- 1 “ASCII Display” field in LW50100
- 4 Bit Switches LB0, LB10, LB20, LB30
And a script to manage the display of the LW50100 field
This script must be call every 100 ms for example.
#include "MacInit.h"
#include
#include
#include // Sleep
void Macro_main(IN *p)
{
MacroInit
//ToDo
int i;
// Function copies a string of 5 characters from a source position to a destination position in LocalWord
void copyString(int sourceStart, int destStart) {
for (i = 0; i < 5; i++) {
LocalWord[destStart + i] = LocalWord[sourceStart + i];
}
}
// Fonction clears the content of a string at a given position in LocalWord
void clearString(int start) {
for (i = 0; i < 5; i++) {
LocalWord[start + i] = 0; // Clear the content
}
}
// Main
static int bitPositions[] = {0, 10, 20, 30}; // Positions of the LB bits to check
static int wordPositions[] = {50000, 50010, 50020, 50030}; // Positions of the corresponding LW strings/messages
static int numBits = sizeof(bitPositions) / sizeof(bitPositions[0]); // Number of bits/messages
int activeBits; // Number of LB at 1
static int currentIndex = 0; // Track of the current position of the loop
for (i = 0; i < numBits; i++) {
if (LocalBit[bitPositions[i]]) {
activeBits++;
}
}
if (activeBits == 0) { // No message to display
clearString(50100);
} else if (activeBits == 1) { // Only 1 message to display
for (i = 0; i < numBits; i++) {
if (LocalBit[bitPositions[i]]) { // Search whch message number to display
copyString(wordPositions[i], 50100);
}
}
} else { // More than 1 message to display
if (currentIndex < numBits) {
if (LocalBit[bitPositions[currentIndex]]) {
copyString(wordPositions[currentIndex], 50100);
sleep(1); // Wait for 1 second
}
currentIndex++; // Move to the next index for the next function call
} else {
currentIndex = 0; // Reset to start over if all bits have been processed
}
}
} // End MacroInit
Here’s the Bit-based scrolling of text messages project