Reading from barcode scanner to a text file in raspberry pi - raspberry-pi

I have a problem that I want to read the input that read by "bar code" and save it to a text file.
Raspberry pi B+ with latest version of wheezy.
"bar code" scanner "data logic q w 2100".

I solved problem with few steps simply:
1) make sure your repo is updated.
2) your barcode scanner is selected as USB KEYBOARD as shown in img:"1.PNG"
[DATALOGIC QW2100 KEYBOARD SELECTION][1][1]: http://i.stack.imgur.com/bxkG2.png
3) in Ubuntu barcode scanner capture data and view it in any window can capture input " terminal or text file " or any other thing.
4) in raspberry pi problem is that barcode scanner captured or read value is made into "/dev/hidraw0" for example.."that file is created auto when your barcode is connected to your raspi.
HERE IS SOME SIMPLE PYTHON CODE TO CAPTURE DATA FROM THAT FILE ONLY WHEN BARCODE IS CONNECTED TO RASPI:
import sys
done = False
while not done:
hid = { 4: 'a', 5: 'b', 6: 'c', 7: 'd', 8: 'e', 9: 'f', 10: 'g', 11: 'h', 12: 'i', 13: 'j', 14: 'k', 15: 'l', 16: 'm', 17: 'n', 18: 'o', 19: 'p', 20: 'q', 21: 'r', 22: 's', 23: 't', 24: 'u', 25: 'v', 26: 'w', 27: 'x', 28: 'y', 29: 'z', 30: '1', 31: '2', 32: '3', 33: '4', 34: '5', 35: '6', 36: '7', 37: '8', 38: '9', 39: '0', 44: ' ', 45: '-', 46: '=', 47: '[', 48: ']', 49: '\\', 51: ';' , 52: '\'', 53: '~', 54: ',', 55: '.', 56: '/' }
hid2 = { 4: 'A', 5: 'B', 6: 'C', 7: 'D', 8: 'E', 9: 'F', 10: 'G', 11: 'H', 12: 'I', 13: 'J', 14: 'K', 15: 'L', 16: 'M', 17: 'N', 18: 'O', 19: 'P', 20: 'Q', 21: 'R', 22: 'S', 23: 'T', 24: 'U', 25: 'V', 26: 'W', 27: 'X', 28: 'Y', 29: 'Z', 30: '!', 31: '#', 32: '#', 33: '$', 34: '%', 35: '^', 36: '&', 37: '*', 38: '(', 39: ')', 44: ' ', 45: '_', 46: '+', 47: '{', 48: '}', 49: '|', 51: ':' , 52: '"', 53: '~', 54: '<', 55: '>', 56: '?' }
fp = open('/dev/hidraw0', 'rb')
ss = ""
shift = False
done = False
while not done:
## Get the character from the HID
buffer = fp.read(8)
for c in buffer:
if ord(c) > 0:
## 40 is carriage return which signifies
## we are done looking for characters
if int(ord(c)) == 40:
done = True
break;
## If we are shifted then we have to
## use the hid2 characters.
if shift:
## If it is a '2' then it is the shift key
if int(ord(c)) == 2 :
shift = True
## if not a 2 then lookup the mapping
else:
ss += hid2[ int(ord(c)) ]
shift = False
## If we are not shifted then use
## the hid characters
else:
## If it is a '2' then it is the shift key
if int(ord(c)) == 2 :
shift = True
## if not a 2 then lookup the mapping
else:
ss += hid[ int(ord(c)) ]
print ss
##DONE
I ADDED FIRST WHILE LOOP TO MAKE SCRIPT WORK CONTINUOUS TILL U KILL IT WITH "CTRL+C".
ANOTHER THING: IMAGE IS FOR DATALOGIC BARCODE CODE SCANNER QW2100 LITE, SO CHECK YOUR BARCODE MANUEL CAREFULLY TOO.

If the LED comes on, I suggest you to boot your raspberry with barcode scanner plug in, open terminal and type:
sudo apt-get update
sudo apt-get upgrade
After that, reboot and open a txt file a try to scan a barcode; Pay attention that barcode is recognized by scanner.
I bought a barcode scanner and I have the same problem me too. In this way I solved.

Related

Buildroot includes host path in python libs and other makefiles in target image - pip install failing

I did a buildroot (2022.08.1) make of a raspberrypi3_defconfig with some changes (include python3, kdb, wpa_supplicant, iwd and some others).
My issue is that if I then run for example pip install python-lirc on the target raspberrypi3, I get an error that some files are missing and setup.py cannot complete.
The issue is that apparently my host system (WSL2 on Win11) paths are somehow included in the target build, as I see the file system structure of my host in the output errors.
For example /mnt/wsl/Kali/buildroot/output/host/opt/ext-toolchain/share/gcc-10.3.1/python
Then I searched for that string /mnt/Kali in all files inside the sdcard.img image which I just unpacked with 7z and get following result:
D:\OutputBuildroot\sdcard\1\lib\libstdc++.so.6.0.28-gdb.py (2 Treffer)
Zeile 22: pythondir = '/mnt/wsl/Kali/buildroot/output/host/opt/ext-toolchain/share/gcc-10.3.1/python'
Zeile 23: libdir = "/mnt/wsl/Kali/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/lib"
D:\OutputBuildroot\sdcard\1\usr\bin\irdb-get (1 Treffer)
Zeile 1: #!/usr/bin/env /mnt/wsl/Kali/buildroot/output/host/bin/python
D:\OutputBuildroot\sdcard\1\usr\bin\irtext2udp (1 Treffer)
Zeile 1: #!/usr/bin/env /mnt/wsl/Kali/buildroot/output/host/bin/python
D:\OutputBuildroot\sdcard\1\usr\bin\lirc-init-db (1 Treffer)
Zeile 1: #!/usr/bin/env /mnt/wsl/Kali/buildroot/output/host/bin/python
D:\OutputBuildroot\sdcard\1\usr\bin\pronto2lirc (1 Treffer)
Zeile 1: #!/usr/bin/env /mnt/wsl/Kali/buildroot/output/host/bin/python
D:\OutputBuildroot\sdcard\1\usr\lib\libstdc++.so.6.0.28-gdb.py (2 Treffer)
Zeile 22: pythondir = '/mnt/wsl/Kali/buildroot/output/host/opt/ext-toolchain/share/gcc-10.3.1/python'
Zeile 23: libdir = "/mnt/wsl/Kali/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/lib"
D:\OutputBuildroot\sdcard\1\usr\lib\python3.10\config-3.10-arm-linux-gnueabihf\Makefile (12 Treffer)
Zeile 33: abs_srcdir= /mnt/wsl/Kali/buildroot/output/build/python3-3.10.7
Zeile 34: abs_builddir= /mnt/wsl/Kali/buildroot/output/build/python3-3.10.7
Zeile 37: CC= /mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-gcc
Zeile 38: CXX= /mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-g++
Zeile 41: AR= /mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-gcc-ar
Zeile 42: READELF= /mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-readelf
Zeile 205: OPENSSL_INCLUDES=-I/mnt/wsl/Kali/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include
Zeile 207: OPENSSL_LDFLAGS=-L/mnt/wsl/Kali/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib
Zeile 220: CONFIG_ARGS= '--target=arm-buildroot-linux-gnueabihf' '--host=arm-buildroot-linux-gnueabihf' '--build=x86_64-pc-linux-gnu' '--prefix=/usr' '--exec-prefix=/usr' '--sysconfdir=/etc' '--localstatedir=/var' '--program-prefix=' '--disable-gtk-doc' '--disable-gtk-doc-html' '--disable-doc' '--disable-docs' '--disable-documentation' '--with-xmlto=no' '--with-fop=no' '--disable-dependency-tracking' '--enable-ipv6' '--disable-nls' '--disable-static' '--enable-shared' '--disable-lib2to3' '--disable-berkeleydb' '--disable-readline' '--disable-curses' '--with-libmpdec=none' '--with-expat=system' '--disable-sqlite3' '--with-openssl=/mnt/wsl/Kali/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr' '--disable-codecs-cjk' '--disable-uuid' '--disable-bzip2' '--disable-xz' '--disable-ossaudiodev' '--without-ensurepip' '--without-cxx-main' '--with-system-ffi' '--disable-pydoc' '--disable-test-modules' '--disable-tk' '--disable-nis' '--disable-idle3' '--disable-pyc-build' 'build_alias=x86_64-pc-linux-gnu' 'host_alias=arm-buildroot-linux-gnueabihf' 'target_alias=arm-buildroot-linux-gnueabihf' 'CC=/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-gcc' 'CFLAGS=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -g0 -D_FORTIFY_SOURCE=1' 'LDFLAGS=' 'CPPFLAGS=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64' 'CPP=/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-cpp' 'PKG_CONFIG=/mnt/wsl/Kali/buildroot/output/host/bin/pkg-config'
D:\OutputBuildroot\sdcard\1\usr\lib\python3.10\lib-dynload\array.cpython-310-arm-linux-gnueabihf.so (1 Treffer)
Zeile 225:
D:\OutputBuildroot\sdcard\1\usr\lib\python3.10\lib-dynload\pyexpat.cpython-310-arm-linux-gnueabihf.so (1 Treffer)
Zeile 197:
D:\OutputBuildroot\sdcard\1\usr\lib\python3.10\lib-dynload\_asyncio.cpython-310-arm-linux-gnueabihf.so (1 Treffer)
Zeile 330:
D:\OutputBuildroot\sdcard\1\usr\lib\python3.10\lib-dynload\_sha3.cpython-310-arm-linux-gnueabihf.so (1 Treffer)
Zeile 149:
D:\OutputBuildroot\sdcard\1\usr\lib\python3.10\lib-dynload\_ssl.cpython-310-arm-linux-gnueabihf.so (1 Treffer)
Zeile 641:
D:\OutputBuildroot\sdcard\1\usr\lib\python3.10\site-packages\lirc-setup\lirc-setup (1 Treffer)
Zeile 1: #!/usr/bin/env /mnt/wsl/Kali/buildroot/output/host/bin/python
D:\OutputBuildroot\sdcard\1\usr\lib\python3.10\_sysconfigdata__linux_arm-linux-gnueabihf.py (21 Treffer)
Zeile 10: 'AR': '/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-gcc-ar',
Zeile 18: 'BLDSHARED': '/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-gcc '
Zeile 24: 'CC': '/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-gcc',
Zeile 59: "'--with-openssl=/mnt/wsl/Kali/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr' "
Zeile 68: "'CC=/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-gcc' "
Zeile 73: "'CPP=/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-cpp' "
Zeile 74: "'PKG_CONFIG=/mnt/wsl/Kali/buildroot/output/host/bin/pkg-config'",
Zeile 78: 'COVERAGE_INFO': '/mnt/wsl/Kali/buildroot/output/build/python3-3.10.7/coverage.info',
Zeile 79: 'COVERAGE_REPORT': '/mnt/wsl/Kali/buildroot/output/build/python3-3.10.7/lcov-report',
Zeile 84: 'CXX': '/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-g++',
Zeile 574: 'LDCXXSHARED': '/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-g++ '
Zeile 580: 'LDSHARED': '/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-gcc '
Zeile 599: 'LINKCC': '/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-gcc',
Zeile 612: 'MAINCC': '/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-gcc',
Zeile 642: 'OPENSSL_INCLUDES': '-I/mnt/wsl/Kali/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/include',
Zeile 643: 'OPENSSL_LDFLAGS': '-L/mnt/wsl/Kali/buildroot/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib',
Zeile 675: 'PYTHON_FOR_BUILD': '_PYTHON_PROJECT_BASE=/mnt/wsl/Kali/buildroot/output/build/python3-3.10.7 '
Zeile 678: '/mnt/wsl/Kali/buildroot/output/build/python3-3.10.7/`cat '
Zeile 740: 'READELF': '/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-readelf',
Zeile 814: 'abs_builddir': '/mnt/wsl/Kali/buildroot/output/build/python3-3.10.7',
Zeile 815: 'abs_srcdir': '/mnt/wsl/Kali/buildroot/output/build/python3-3.10.7',
D:\OutputBuildroot\sdcard\1\usr\lib\python3.10\__pycache__\_sysconfigdata__linux_arm-linux-gnueabihf.cpython-310.pyc (17 Treffer)
Zeile 12: AIX_BUILDDATEZAIX_GENUINE_CPLUSPLUSZALIGNOF_LONGé
Zeile 15: BLDLIBRARYz-L. -lpython3.10Z BLDSHAREDzL/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-gcc -sharedZBUILDEXEZBUILDPYTHONZpythonZBUILD_GNU_TYPEzx86_64-pc-linux-gnuZBYTESTR_DEPSú\ZCCzD/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-gccZCCSHAREDz-fPICZCFLAGSz–-Wno-unused-result -Wsign-compare -DNDEBUG -g -O3 -Wall -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -g0 -D_FORTIFY_SOURCE=1ZCFLAGSFORSHAREDZCFLAGS_ALIASINGZ
Zeile 16: CFLAGS_NODISTZCONFIGFILESz?configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.inZCONFIGURE_CFLAGSz]-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -Os -g0 -D_FORTIFY_SOURCE=1ZCONFIGURE_CFLAGS_NODISTz§-std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -fvisibility=hiddenZCONFIGURE_CPPFLAGSz#-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64ZCONFIGURE_LDFLAGSZCONFIGURE_LDFLAGS_NODISTZCONFIG_ARGSaÒ
Zeile 18: COVERAGE_INFOzA/mnt/wsl/Kali/buildroot/output/build/python3-3.10.7/coverage.infoZCOVERAGE_REPORTz?/mnt/wsl/Kali/buildroot/output/build/python3-3.10.7/lcov-reportZCOVERAGE_REPORT_OPTIONSz2--no-branch-coverage --title "CPython lcov report"ZCPPFLAGSzP-I. -I./Include -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64ZCXXzD/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-g++ZDESTDIRSzA/usr /usr/lib /usr/lib/python3.10 /usr/lib/python3.10/lib-dynloadZDESTLIBZDESTPATHZ
Zeile 107: INSTSONAMEzlibpython3.10.so.1.0ZIO_HzModules/_io/_iomodule.hZIO_OBJSZLDCXXSHAREDzL/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-g++ -sharedZLDFLAGSZLDFLAGS_NODISTZ LDLIBRARYzlibpython3.10.soZLDLIBRARYDIRZLDSHAREDZ LDVERSIONz3.10ZLIBCZLIBDESTZLIBDIRz/usr/libZLIBFFI_INCLUDEDIRZLIBMz-lmZ LIBOBJDIRzPython/ZLIBOBJSZLIBPCz/usr/lib/pkgconfigZLIBPLz3/usr/lib/python3.10/config-3.10-arm-linux-gnueabihfZ LIBPYTHONZLIBRARYzlibpython3.10.aZLIBRARY_DEPSz.libpython3.10.a libpython3.10.so libpython3.soZLIBRARY_OBJSZLIBRARY_OBJS_OMIT_FROZENZLIBSz,-lcrypt -lpthread -ldl -lpthread -lutil -lmZ
Zeile 110: LLVM_PROF_ERRZLLVM_PROF_FILEZLLVM_PROF_MERGERÚtrueZLNZlnZLOCALMODLIBSZMACHDEPZlinuxZMACHDEP_OBJSZMACHDESTLIBZMACOSX_DEPLOYMENT_TARGETZMAINCCZMAJOR_IN_MKDEVZMAJOR_IN_SYSMACROSZ MAKESETUPz./Modules/makesetupZMANDIRz/usr/share/manZMKDIR_Pz/usr/bin/mkdir -pZMODBUILT_NAMESzÇposix errno pwd _sre _codecs _weakref _functools _operator _collections _abc itertools atexit _signal _stat time _thread _locale _io faulthandler _tracemalloc _symtable xxsubtypeZMODDISABLED_NAMESZMODLIBSZMODOBJSab
Zeile 117: PYTHONPATHZPYTHON_FOR_BUILDaI
Zeile 120: QUICKTESTOPTSz)-x test_subprocess test_io test_lib2to3 \ZREADELFzH/mnt/wsl/Kali/buildroot/output/host/bin/arm-none-linux-gnueabihf-readelfZ RESSRCDIRzMac/Resources/frameworkZ
Zeile 138: XMLLIBSUBDIRSz)xml xml/dom xml/etree xml/parsers xml/saxZabs_builddirz3/mnt/wsl/Kali/buildroot/output/build/python3-3.10.7Z
D:\OutputBuildroot\sdcard\1\usr\sbin\lircd-setup (1 Treffer)
Zeile 1: #!/usr/bin/env /mnt/wsl/Kali/buildroot/output/host/bin/python
What could be the bug that those paths are included in my build?

Data needed to train Tesseract OCR for custom Language

I am trying to build a CUSTOM language for detecting only following characters:
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1',
'2', '3', '4', '5', '6', '7', '8', '9', '<', '<<<', '/']
I have almost 50 images for which I have generated box files corrected the errors.
My question is for training tesseract for the above customized characters is it needed to use images which were created by tesseract tool to be used also as an input while creating cust.traindata
I have made a code which from the above array takes 5 character and builds an image using tesseract tool and then later generates the .box file which is proper and doesn't need tunning for all possible configurations but since tesseract as created it does it need to be given for building the cust.traindata.
Thanks in advance.
We don't need to create a new language if we want tesseract to use default "eng" language to predict following letters
['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '<', '<<<', '/']
You just need to add following configuration to tesseract tessedit_char_whitelist="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<"
eg.
tesseract input_image output_text -l eng -c tessedit_char_whitelist="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<"

Powershell .TrimEnd not returning correct result

Running the following
$x = "CF21_flddep-op-config"
$x.TrimEnd("-op-config")
Results in:
CF21_fldde
When it should be displaying:
CF21_flddep
Any ideas why?
.TrimEnd() does not remove a trailing string, it removes a set of trailing characters. p is in that set, so the last p is also removed. (You would get the same result with .TrimEnd("-cfginop"), or more explicitly .TrimEnd('-', 'c', 'f', 'g', 'i', 'n', 'o', 'p').) You want something like $x -replace "-op-config", "" or, if the string must only be removed when it occurs at the end, -replace "-op-config$", "".

qbasic-What is wrong with my code?I'm not getting what i want

I tried to make a simple login program using qbasic. I used 3 sub modules and 1 main module. Here is the code:
DECLARE SUB login ()
DECLARE SUB menu ()
DECLARE SUB REGISTER ()
CLS
CALL menu
END
SUB login
OPEN "USERPASS.TXT" FOR INPUT AS #2
CLS
97
LOCATE 2, 30: PRINT "LOGIN"
LOCATE 4, 10: INPUT "PLEASE ENTER CORRECT USERNAME OR PRESS B IF YOU WANT TO GO BACK"; USER$
IF UCASE$(USER$) = "B" THEN
CLOSE #2
CALL menu
ELSE
DO WHILE NOT EOF(2)
INPUT #2, U$, p$
IF U$ = USER$ THEN
TEMPUSER$ = U$
PASSWORDS$ = p$
EXIT DO
END IF
LOOP
END IF
IF USER$ = TEMPUSER$ THEN
98
PRINT PASSWORDS$
LOCATE 5, 30: INPUT "ENTER PASSWORD OR PRESS B if you want to go back"; password$
IF UCASE$(password$) = "B" THEN
GOTO 97
ELSE
IF password$ = PASSWORDS$ THEN
PRINT "HURRAY YOU LOGGED IN"
ELSE
GOTO 98
END IF
END IF
ELSE
GOTO 97
END IF
CLOSE #2
END SUB
SUB menu
CLS
23
LOCATE 2, 30: PRINT "MAIN MENU"
LOCATE 4, 30: PRINT "1.LOGIN"
LOCATE 5, 30: PRINT "2.REGISTER"
LOCATE 6, 30: INPUT "PLEASE! Enter 1 or 2"; a
IF a = 1 THEN
CALL login
ELSE
IF a = 2 THEN
CALL REGISTER
ELSE
CLS
GOTO 23
END IF
END IF
END SUB
SUB REGISTER
CLS
OPEN "userpass.txt" FOR APPEND AS #1
LOCATE 2, 30: PRINT "REGISTER MENU"
LOCATE 4, 30: INPUT "ENTER NEW USERNAME"; NEWU$
CLS
LOCATE 4, 30: INPUT "ENTER NEW PASSWORD"; PASSU$
WRITE #1, NEWU$, PASSU$
END SUB
Everything is as my desire but in sub module login something is wrong I guess. The login massage does not come even if I enter correct password and username. But if I enter username which does not exist, it shows the login message. Please help. Thanks in advance.
You're missing an END IF to match ELSEIF UCASE$(USER$) <> "B" THEN (by the way: if UCASE$(USER$) = "B" is false, then UCASE$(USER$) <> "B" is true, so you could simply say ELSE there).
You might try indenting in a bit more conventional manner:
every IF, ELSEIF, ELSE, and END IF that matches is in the same column, and
everything inside those statements is indented a few more spaces.
The same indentation rules can be applied to SELECT CASE, WHILE-WEND, DO-LOOP, and FOR-NEXT.
Anyway, you might see the missing END IF if you did that:
SUB login
OPEN "USERPASS.TXT" FOR INPUT AS #2
CLS
97
LOCATE 2, 30: PRINT "LOGIN"
LOCATE 4, 10: INPUT "PLEASE ENTER CORRECT USERNAME OR PRESS B IF YOU WANT TO GO BACK"; USER$
IF UCASE$(USER$) = "B" THEN
CLOSE #2
CALL menu
ELSEIF UCASE$(USER$) <> "B" THEN
WHILE NOT EOF(2)
INPUT #2, U$, p$
IF U$ = USER$ THEN
TEMPUSER$ = U$
PASSWORDS$ = p$
END IF
WEND
IF USER$ = TEMPUSER$ THEN
98
PRINT PASSWORDS$
LOCATE 5, 30: INPUT "ENTER PASSWORD OR PRESS B if you want to go back"; password$
IF UCASE$(password$) = "B" THEN GOTO 97
ELSEIF UCASE$(password$) <> "B" THEN
IF password$ = PASSWORDS$ THEN
PRINT "HURRAY YOU LOGGED IN"
ELSE
GOTO 98
END IF
END IF
ELSE
GOTO 97
END IF
CLOSE #2
END SUB

Replace once part of the query in Emacs

I have such requirement for search&replace in Emacs:
I have a bunch of
'A', 'High'
'B', 'High'
'C', 'High'
'D', 'High'
And the list goes on.
I want to replace them to be:
A = 'High'
B = 'High'
C = 'High'
D = 'High'
Can I query for the pattern, say '#', 'High' and replace it with #= 'High?
Move point to beginning of buffer.
M-x query-replace-regexp.
Enter '\([^']+\)', '\([^']+\)' as regexp and \1 = '\2' as replacement.
Press ! to replace all at once, or keep pressing y/n
for each match.