variables

Windows Batch: Split String to individual characters to variables

丶灬走出姿态 提交于 2020-01-25 05:36:30
问题 in Windows Batch, if I had a variable (length can change) that was, for example: "hello world!" is it possible to "split" the variable so each character is its own variable so the output could look like: t1=h t2=e t3=l etc. Any help would be appreciated. 回答1: Use this code: setlocal EnableDelayedExpansion set str="hello world^!" set tempstr=%str% set count=0 :loop if defined tempstr ( set tempstr=%tempstr:~1% set /a count+=1 set /a pos=%count%-1 set t!count!=!str:~%pos%,1! goto loop ) ::

Access local variable from outside the function

情到浓时终转凉″ 提交于 2020-01-25 05:21:05
问题 I'm using TopUp to make a simple slideshow. Unfortunately they don't expose the image index. Is there a way I can access the local variable "index" without having to modify the original script? TopUp = (function() { var index = null; ... } 回答1: Without modifying the original script, you can't. But if you just want to be able to read the value of index , the modification could be really simple, by adding a little function in the objet returned : getIndex : function() { return index; }, 回答2:

Sharing variables between 2 separate scripts [duplicate]

浪子不回头ぞ 提交于 2020-01-25 00:22:22
问题 This question already has an answer here : Get 2 userscripts to interact with each other? (1 answer) Closed 2 years ago . I'm trying to share variable between 2 different Tampermonkey scripts running in 2 separate tabs. I tried using GM_setValue in one script then retrieving it with GM_getValue in the other one but without any success, so I assume there's separate storage for each script. Is there any easy way to do this? Am I just missing something simple? Can I somehow make both scripts

sed replace variables while read lines

♀尐吖头ヾ 提交于 2020-01-25 00:07:15
问题 I'm working on a shell script and i need to change some strings from different lines of a file into a while read statement. The structure need to be like this, because the String_Search and String_result will be calculated on each line. while read line do varA="String_Search" resA="String_Result" line=`echo $line | sed -e "s/$varA/$resA"` echo $line >> outputFile.txt done < "inputFile.txt" The script doesn't works and its showing to me this error message: sed: -e expression #1, char 31:

sed replace variables while read lines

微笑、不失礼 提交于 2020-01-25 00:06:44
问题 I'm working on a shell script and i need to change some strings from different lines of a file into a while read statement. The structure need to be like this, because the String_Search and String_result will be calculated on each line. while read line do varA="String_Search" resA="String_Result" line=`echo $line | sed -e "s/$varA/$resA"` echo $line >> outputFile.txt done < "inputFile.txt" The script doesn't works and its showing to me this error message: sed: -e expression #1, char 31:

which variable parts are stored to the stack in this code?

情到浓时终转凉″ 提交于 2020-01-24 22:55:30
问题 I have this following code and I don't really understand which variable parts in the test_function are stored onto the stack segment? In the book it says "The memory for these variables is in the stack segment", so I presume it is when the variables are actually initialized to a value. Right? void test_function(int a, int b, int c, int d) { int flag; //is it this char buffer[10];// and this //or flag = 31337; //this and buffer[0] = 'A'; //this. Or all of it? } int main() { test_function(1, 2,

Unused variable detection in SQL Server

霸气de小男生 提交于 2020-01-24 20:12:34
问题 Is there a way to identify local variables that have been created (or even created and set to a value), but are never used again? I'm thinking along the lines of when an IDE will underline such variables with a squiggly line. If this isn't something that can be enabled within SSMS, are there any add-ins that do this? (Particularly interested in SQL Server 2008 R2, if it matters) Thanks for the insight. 回答1: ApexSQL Refactor, a free SSMS and VS SQL formatting and refactoring add-in, has a

Using >nul in a variable

泄露秘密 提交于 2020-01-24 19:50:21
问题 Does anyone know how to stop >nul being ignored when set in a variable, or is this not possible? I have a feeling that it's one of those things that will only work once all variables have been expanded or something, but it can't hurt to ask. Example: @echo off :: Won't work SET pause_5=ping localhost /n 6 >nul %pause_5% :: Will work SET pause_5=ping localhost /n 6 %pause_5% >nul exit 回答1: Put quotes around the argument: set "pause_5=ping localhost /n 6 >nul" Another option is to escape

Google/Typekit Webfont-Loader does not detect non-ASCII fonts

删除回忆录丶 提交于 2020-01-24 14:12:46
问题 I'm using the Google webfont loader, but I can't get the fontactive callback to work. The font is rendering on the page, but for some reason the callback isn't firing. (Instead it waits for 5 seconds and then the fontinactive callback fires.) I suspect the problem is in how I'm declaring the two variables to the function. Edit: The problem may have to do with the font, not how I'm declaring the variable. The font-loader sucessfully detects when the "STIXGeneral" font family loads, which

let and var Invalid redeclaration of const in Swift REPL

本秂侑毒 提交于 2020-01-24 12:32:53
问题 In Swift REPL I can assign a constant with let , but why can I modify it later using var ? let name = "al" var name = "bob" Swift is not complaining here, but wasn't name a constant? 回答1: Redeclaring a variable (in the same scope) is not valid in Swift: $ cat test.swift let name = "al" var name = "bob" $ swiftc test.swift test.swift:2:5: error: invalid redeclaration of 'name' var name = "bob" ^ test.swift:1:5: note: 'name' previously declared here let name = "al" ^ However, the Swift REPL