kyoneko Posted January 29, 2013 Share Posted January 29, 2013 (edited) It has been a looong time since i have scripted anything with SCAR and most of my knowledge faded away to somewhere. But today i wanted to use it but i cant figure out how to do it anymore. My basic idea is i want to type in a number by const L1. And then have L2 deduct 2 from that number. After that i want to have L2 writen somewhere on a external place like notepad or excel. What i have untill now does not seem to work in the slightest. Both calculating L2 and writing it out isn;t working properly. Here is my script in the hope someone can tell me what im doing wrong. const L1 = '281'; var L2 : integer; begin L2 := L1-2; wait(2000) typetext (L2) end. Kyon. EDIT: I found part of the solution already. I had to replace typetext (L2) with typetext (IntToStr(L2)). But that still leaves the calculation itself thats not working yet. Edited January 29, 2013 by kyoneko Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted January 29, 2013 Share Posted January 29, 2013 You have L1 as a constant string value, not an integer value. [sCAR]const L1 = 281;[/sCAR] Quote Link to comment Share on other sites More sharing options...
kyoneko Posted January 29, 2013 Author Share Posted January 29, 2013 Ah ofcourse. That makes sence, thank you very much. How i managed to overlook that i dont even know. A other slight question. If i want to add a tab or a enter after that. How do i do that? I recall in the past it used to be something like sendchar(108) or keydown(108). But i cant seem ot figure out how to do that now. Quote Link to comment Share on other sites More sharing options...
Bixby Sayz Posted January 29, 2013 Share Posted January 29, 2013 Ah ofcourse. That makes sence, thank you very much. How i managed to overlook that i dont even know. A other slight question. If i want to add a tab or a enter after that. How do i do that? I recall in the past it used to be something like sendchar(108) or keydown(108). But i cant seem ot figure out how to do that now. VK_TAB and VK_RETURN??? Don't do a lot with keycodes. I always have to look them up. Quote Link to comment Share on other sites More sharing options...
kyoneko Posted January 29, 2013 Author Share Posted January 29, 2013 I just tried that. But they give me internall error(20). Also cant find anything about that code or anything in the manual. Quote Link to comment Share on other sites More sharing options...
Janilabo Posted January 29, 2013 Share Posted January 29, 2013 (edited) TypeText(IntToStr(L2)); Edit: Oops, this was noticed already.. ..wait, what exactly are you trying to do? You can do enter like this: TypeText(IntToStr(L2) + #13); ..or... TypeText(IntToStr(L2) + Chr(13)); Edited January 29, 2013 by Janilabo Quote Link to comment Share on other sites More sharing options...
kyoneko Posted January 29, 2013 Author Share Posted January 29, 2013 (edited) TypeText(IntToStr(L2)); I already stated in my first post i managed to solve that issue. But thanks for trying anyways. I got a extra minor problem. If i try to make L1 a decimal number. Like 281,5. I get a error message saying indentifier expected. Any way to get around this or push it through anyway? I tried to use a devide 1 by 2 to get a half and add that to 281. But neiter : nor / seems to devide anything. ..wait, what exactly are you trying to do? Quite simple really. I want to make a bigger script which takes a number. Substracts and adds some numsers in diffrend variables. Then writes those out and presses enter. To make it simpler i conpressed it to one simpler part. All i need to know now is how to put in a command to make it press enter or tab. And now a resent problem is to figure how to put in decimal numbers. You can do enter like this: That worked indeed. Thank you very much. Now just the last minor thing and my day wouldn;t be able to get any better Edited January 29, 2013 by kyoneko Quote Link to comment Share on other sites More sharing options...
Janilabo Posted January 29, 2013 Share Posted January 29, 2013 (edited) const L1 = 281; var L2: Extended; begin L2 := (L1 - 0.5); Wait(2000) TypeText(FloatToStr(L2) + #13); end. Or: const L1 = 281.5; var L2: Extended; begin L2 := (L1 - (1 / 2)); Wait(2000) TypeText(FloatToStr(L2) + #13); end. Edited January 29, 2013 by Janilabo Quote Link to comment Share on other sites More sharing options...
kyoneko Posted January 29, 2013 Author Share Posted January 29, 2013 Thank you very much. Everything is working perfectly now. Quote Link to comment Share on other sites More sharing options...
Janilabo Posted January 29, 2013 Share Posted January 29, 2013 Thank you very much. Everything is working perfectly now.Great that you got it working! Quote Link to comment Share on other sites More sharing options...
kyoneko Posted January 31, 2013 Author Share Posted January 31, 2013 The script itself works as it should. But there is just one minor problem it gives me now. Sometimes when i ask it to write out its things it writes out decimal numbers with a comma in betwene, and somtimes with a period. I have no idea what makes it switch, or how to make it switch back. Normally this wont bother me but hte programm i use it on only accepts comma's. Anyone got any idea what makes SCAR switch betwene these two and how to make it switch when i want it to? Quote Link to comment Share on other sites More sharing options...
Janilabo Posted January 31, 2013 Share Posted January 31, 2013 (edited) No idea what causes this problem that you reported here, but here is a workaround, that you could use in your script: function FloatToStrD(e: Extended): string; begin Result := Replace(FloatToStr(e), ',', '.'); end; function FloatToStrC(e: Extended): string; begin Result := Replace(FloatToStr(e), '.', ','); end; begin WriteLn('Hey, this works: ' + FloatToStrD(1.2345)); WriteLn('Hey, this works: ' + FloatToStrC(1.2345)); end. -Jani Edited January 31, 2013 by Janilabo Quote Link to comment Share on other sites More sharing options...
kyoneko Posted January 31, 2013 Author Share Posted January 31, 2013 Thanks for the awnser. While your solution seems to work by itself. I have simply no idea how i can apply this to a larger script i use. Quote Link to comment Share on other sites More sharing options...
Janilabo Posted January 31, 2013 Share Posted January 31, 2013 (edited) Add those functions in your script and then replace all of the FloatToStr's with the method you need at certain parts of it? - - - Updated - - - Here is couple other workarounds, btw: var decimalSeparator: Char; function FloatToStr2(e: Extended): string; begin Result := Replace(Replace(FloatToStr(e), ',', '.'), '.', decimalSeparator); end; begin ClearDebug; WriteLn('Hey, this works: ' + FloatToStr2(1.2345)); decimalSeparator := ','; WriteLn('Hey, this works: ' + FloatToStr2(1.2345)); decimalSeparator := '.'; WriteLn('Hey, this works: ' + FloatToStr2(1.2345)); decimalSeparator := ','; WriteLn('Hey, this works: ' + FloatToStr2(1.2345)); end. ..or... function FloatToStrEx(e: Extended; decSep: Char): string; begin Result := Replace(Replace(FloatToStr(e), ',', '.'), '.', decSep); end; begin ClearDebug; WriteLn('Hey, this works: ' + FloatToStrEx(1.2345, ' ')); WriteLn('Hey, this works: ' + FloatToStrEx(1.2345, ',')); WriteLn('Hey, this works: ' + FloatToStrEx(1.2345, '.')); WriteLn('Hey, this works: ' + FloatToStrEx(1.2345, ',')); end. Edited January 31, 2013 by Janilabo Quote Link to comment Share on other sites More sharing options...
kyoneko Posted January 31, 2013 Author Share Posted January 31, 2013 (edited) Well yes. I tried that but i get Internal error (20) When i try that. I'll just pull out a part of my script to hopefully make it easyer. var A1, A1h, A1l, A1max, A1min : extended; begin A1 := 400; A1h := 0.4; A1l := 0.4; A1max := A1+A1h; A1min := A1-A1l; wait(2000) typetext(FloatToStr(A1) + #9 + FloatToStr(A1max) + #9 + FloatToStr(A1min)); end. If i try to apply your code i get something like this. var A1, A1h, A1l, A1max, A1min : extended; function FloatToStrC(e: Extended): string; begin Result := Replace(FloatToStr(e), '.', ','); end; begin A1 := 400; A1h := 0.4; A1l := 0.4; A1max := A1+A1h; A1min := A1-A1l; wait(2000) typetext(FloatToStrC(A1) + #9 + FloatToStrC(A1max) + #9 + FloatToStrC(A1min)); end. OR i get var A1, A1h, A1l, A1max, A1min : extended; function FloatToStrC(e: Extended): string; begin Result := Replace(FloatToStr(e), '.', ','); end; begin A1 := 400; A1h := 0.4; A1l := 0.4; A1max := A1+A1h; A1min := A1-A1l; wait(2000) typetext(FloatToStrC(FloatToSt(rA1)) + #9 + FloatToStrC(FloatToStr(A1max)) + #9 + FloatToStrC(FloatToStr(A1min))); end. Neiter of them seem to be working for me Edited January 31, 2013 by kyoneko Quote Link to comment Share on other sites More sharing options...
Janilabo Posted January 31, 2013 Share Posted January 31, 2013 Look at the bottom of the script.. "end" => "end.". Quote Link to comment Share on other sites More sharing options...
kyoneko Posted January 31, 2013 Author Share Posted January 31, 2013 That is just a mistake on my part from copying the sript to here with taking out the parts. In the script i have running there is a period behind the last end. So that isn;t the mistake. I would get a expected "." error instead if that was it. Quote Link to comment Share on other sites More sharing options...
Janilabo Posted January 31, 2013 Share Posted January 31, 2013 Those scripts, with "end." work just fine for me? I am using SCAR Divi 3.38. Quote Link to comment Share on other sites More sharing options...
kyoneko Posted January 31, 2013 Author Share Posted January 31, 2013 Well. That is certainly odd. I just retried it and it worked as well. Cant say i did anything diffrend at all. Eiter way thank you again for the help. Dont know it its related. but im using SCAR Devi 3.38 Portable edition because the place i work doesn;t allow me to install things. Quote Link to comment Share on other sites More sharing options...
Janilabo Posted January 31, 2013 Share Posted January 31, 2013 (edited) The bottom one of em is however problematic. 1. There's some typos in it. 2. Do NOT use FloatToStr inside FloatToStr[C|D|2|Ex]. That wont obviously work, because it would be incorrect type (string <> extended). Simply, replace all the FloatToStr's with the function you are looking for (FloatToStr2, FloatToStrEx, FloatToStrC, FloatToStrP). -Jani Edited January 31, 2013 by Janilabo Quote Link to comment Share on other sites More sharing options...