Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to output str variable as text?
#1
Noobie here, non-programmer.
Please help me understand my error in this macro. It is intended to produce the current date with format 2014-0303. Thank you!

Code:
Copy      Help
str s
s.timeformat("{yyyy-MMdd}")
s             ;; output date as 2014-0405
The error message says
Error in yyyy-MMdd: syntax.

-------
EDIT: Ok, now I realize that the error is in the third line. So my new question is "How can I output the formatted date (or any string variable) as text?"

-------
EDIT 2: Got it (condensing the last two lines into one):
Code:
Copy      Help
paste s.timeformat("{yyyy-MMdd}")
#2
by use F to format the string then enclosing the string in {}

Macro Macro4
Code:
Copy      Help
str f
f = "fox"
out F"What does the {f} say"
#3
j0nezn Wrote:by use F to format the string then enclosing the string in {}
What function is F? I can't find it in the help file.

Also, my specific need was to output the string variable as text. Thus I needed "paste" instead of "out".
#4
You can find more info about the operator 'F' in the help.
Using the 'help search':
Strings with variables

Or navigating to it manually:
Variables, constants, numbers, strings >> Strings with variables

The 'out' was to show that the '{f}' contents => "fox"
You can put everything after the 'out' in a variable.
Once have the desired contents in you variable, in this case 'f' you can do pretty much anything with it.

If you want to paste:

Macro Macro37
Code:
Copy      Help
;; Placed a 3 second pause if you wanted to run this macro
;; It gives you time to put the mouse pointer/cursor on a desired location
3

;;The output has been put in a variable 's'
str y
y="fox"
str s=F"What does the {y} say"

;; Two examples of 'pasting' using "paste" or "setsel"
paste s
s.setsel
#5
r0n: Thanks very much for the expanded explanation more suitable for a noobie such as myself. QM has a pretty steep learning curve for non-programmers; nearly everything in the Help file or this forum assumes significant background knowledge, so it is difficult to break in.

If anyone can recommend a simple introduction to the general task of programming (that is, starting from the very basics such as terminology and foundational concepts) I'd be grateful.


Forum Jump:


Users browsing this thread: 1 Guest(s)