SRL Archive - Suggestions

Key(integer):char;


Feroc1ty

2010-10-04 01:21:30

Not sure if this exists or not but it would be cool to have a Key(int):char; function, for writing stuff onto files and that sort of stuff…

Sorry to waste your time if it exists already, but it's not documented under FunctionList.

TomTuff

2010-10-04 01:27:17

like SendKeys();?

Feroc1ty

2010-10-04 01:55:55

SendKeys() types in keys, I want a character, specifically key "13" to be written to a text file.

Dgby714

2010-10-04 02:02:18

Feroc1ty, You can write key 13 a few ways. #13 or Chr(13)

Windows Newline
Sendkeys(#13#10);

Linux Newline
Sendkeys(#10);

Daniel

2010-10-04 02:51:29

WriteFileString, etc.

For more file operations, please see: http://wizzup.org/simbadoc/scriptref/files.html

The method names are quite self-explanatory :)

Feroc1ty

2010-10-04 22:18:08

From: Dgby714
Feroc1ty, You can write key 13 a few ways. #13 or Chr(13)

Windows Newline
Sendkeys(#13#10);

Linux Newline
Sendkeys(#10);


thx!


edit: actually it didn't work in the way I wanted it to…

WriteFileString(integer,Chr(13)); 

It puts a weird symbol rather than adding a return to the text file making the text separate lines, I tried '\n', is there something similar to endline function?

Narcle

2010-10-04 22:38:38

From: Feroc1ty
thx!


edit: actually it didn't work in the way I wanted it to…

WriteFileString(integer,Chr(13)); 

It puts a weird symbol rather than adding a return to the text file making the text separate lines, I tried '\n', is there something similar to endline function?


IF your trying to write a series of strings to a file and make a new line #13#10 should work.

Example:
'first line' +#13#10 +'second line' +#13#10+ 'third line'
That in the WriteFileString should produce 3 lines.

Line break requires both #13 and #10 in FileString.

Feroc1ty

2010-10-04 23:05:19

thanks ur cute, made a constant newl to be #13#10 and its simple as 1 2 3

Daniel

2010-10-05 06:24:28

From: Narcle
Line break requires both #13 and #10 in FileString.


For Windows.

So, if you want your Simba script to be cross-platform, it'd be best to do:

var
Str: String;
begin
{$ifDef MSWINDOWS}
Str := 'Hello!' + #13#10 + 'Line 2 (you're using Microsoft Windows)!';
{$else}
Str := 'Hello!' + #10 + 'Line 2 (you're using an operating system other than Microsoft Windows!)';
{$endIf}

WriteFileString(.....

I know #13#10 will work in UNIX OS's, but on memory, I think it produces two line breaks? (on memory!!) You'll have to get someone to confirm though.

Dgby714

2010-10-05 07:52:52

[QUOTE=Dan's The Man;741248]For Windows.

So, if you want your Simba script to be cross-platform, it'd be best to do:

var
Str: String;
begin
{$ifDef MSWINDOWS}
Str := 'Hello!' + #13#10 + 'Line 2 (you're using Microsoft Windows)!';
{$else}
Str := 'Hello!' + #10 + 'Line 2 (you're using an operating system other than Microsoft Windows!)';
{$endIf}

WriteFileString(.....

I know #13#10 will work in UNIX OS's, but on memory, I think it produces two line breaks? (on memory!!) You'll have to get someone to confirm though.

If your doing a constant it would be
const
NewLine = {$IFDEF Windows}#13{$ENDIF}#10;