|
Post by ptitjoz on Nov 8, 2017 16:15:21 GMT 1
Hello,
how to recover info without putting on the hard drive, please ? currently I have done so to recover the name of the graphics card. This name appears at the beginning of the 2nd line just before a space.
REM found name of graphic card PRINT EXEC$("xrandr > tmp.tmp") OPEN "tmp.tmp" FOR READING AS myfile READLN carte$ FROM myfile READLN carte$ FROM myfile CLOSE FILE myfile carte$=LEFT$(carte$,INSTR(carte$," ")) PRINT "Name of Card : ",carte$ key=GETKEY Result :
Name of Card : DSI1 Thanks you for your help
Regards
|
|
|
Post by vovchik on Nov 8, 2017 16:37:46 GMT 1
Dear ptitjoz,
There are a few ways of doing this, and this is one of them:
DECLARE carte$ TYPE STRING carte$ = EXEC$("xrandr") PRINT "Name of card: ", TOKEN$(TOKEN$(carte$, 2, NL$), 1) key = GETKEY
Or, we can "golf" if a bit, getting all the card info into one line of code:
DECLARE carte$ TYPE STRING carte$ = TOKEN$(TOKEN$(EXEC$("xrandr"), 2, NL$), 1) PRINT "Name of card: ", carte$ key = GETKEY
With kind regards, vovchik
|
|
|
Post by ptitjoz on Nov 8, 2017 20:02:04 GMT 1
Oh, I'm impressed! it's perfect ! Now I need to extract another string. the bash syntax is "xrandr --verbose | grep -m 1 -i brightness | cut -f2 -d" " so I did this
DECLARE carte$ TYPE STRING value$=TOKEN$(TOKEN$(EXEC$("xrandr --verbose | grep -m 1 -i brightness | cut -f2 -d ' ' "),1, NL$), 1) PRINT value$ the result is 0.35 and it's the good value
I guess I do not need to do a "grep" and a "cut" because Basicon can do that directly ?
Best regards
|
|
|
Post by vovchik on Nov 8, 2017 20:28:28 GMT 1
Dear ptitjoz,
Try this - it's one way of doing it:
value$ = INBETWEEN$(EXEC$("xrandr --verbose"), "Brightness: ", NL$)
With kind regards, vovchik
|
|
|
Post by ptitjoz on Nov 8, 2017 21:24:41 GMT 1
Perfect !
Thanks you very much !!
Best regards
|
|