Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can I call a function from a menu, pass a argument then run?
#4
There are several ways to pass strings to functions.

1. Function begins with

function lpstr's

(or function $s, because $ is shortcut for lpstr). Then you can pass any string. If you accidentally try to pass a number, you get error. I use this in most functions. But if you don't know what is lpstr and how to use it, use method 2, or within the function assign s to a str variable.

2. Function begins with

function str's

(or function ~s, because ~ is shortcut for str). Then you can pass any string or number. Numbers are automatically converted. Advantages: easiest, does not require knowledge about lpstr; can be manipulated using str functions without at first storing to a str variable. Disadvantages: whole string is copied, which is slower and in case of large strings requires much memory; not error if you accidentally pass a number.

3. Function begins with

function str&s

(or function ~&s). Then you must pass a str variable. The function can modify the variable. Usually used to return values (instead of using ret).

Also can be used str*s. Similar to 3, but requires knowledge about working with pointers.


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)