07-07-2017, 03:28 PM
Function Macro19
;;********************************************************
;;*
;;*
;;* 2 examples about getting a line.
;;* Example 1, get FIRST LINE
;;* Example 2, get THIRD LINE
;;*
;;*
;;********************************************************
;;
;Assuming '1.txt' contains:
;abc
;def
;ghi
;; EXAMPLE 1
str s="$desktop$\1.txt" ;; This is the path to the desktop
str get_text.getfile(s) ;; variable 'get_text' contains the contents of the path in 's'
str first_line.getl(get_text 0)
first_line.setclip ;; put the 'first_line' into clipboard
out first_line
;; EXAMPLE 2 (uses integer variable 'i' to set which line to grab, '2' means 'THIRD' line! ('getl' uses ZERO index, meaning first item = 0 (0,1,2,...))
int i=2
get_text.getfile(s)
str third_line.getl(get_text i)
third_line.setclip
out third_line
;; To GET the clipboard contents
str geclipboard.getclip
out geclipboard
;; If you do NOT understand below explanation, then just do this
;; str s="C:\Users\User\Desktop\1.txt"
;; $desktop$ , is special folder indication for the desktop path in windows
;; if you execute the below, it will output THE FULL ABSOLUTE path of your desktop location:
;;---------
;; str s="$desktop$\1.txt"
;; s.expandpath
;; out s
;;---------
;; Then below in the output pane the FULL path to the desktop will be displayed.
;; You do not have to execute the command "s.expandpath" if you use $-paths
;; only if you need to see/use the full absolute path. QM can process $-paths without having
;; to use .expandpath. BUT YOU MUST USE EXISTING $-paths
;; To see other existing $-Paths which can be used in QM, above in QM in the toolbar
;; in the top right toolbar with pen/hand icon click the 6th icon 'folder with spyglass icon'
;; if you hover over it, shows 'Files/web' click on it, select FIRST item 'Run program',
;; a dialog appears. In the top of that dialog you see a button called 'SF' (somewhere at th top left)
;; click on it and you see all the special folders.
;; If you select 'Cookies' for example, it will fill in the inputfield '$Cookies$\' NOTE THE ENDING BACKSLASH
;; This handy when you compile your macro/function to .exe and then use it on other pc
;; If other pc has different Desktop path, using $Desktop$ will always correctly resolve to
;; correct Desktop path.
;; You can DRAG a textfile into the QM editor and it will automatically create the 'run ...' command
;; and if you drag from a location that has a special folder ($-folder) associated with, in this example
;; you could DRAG the '1.txt' file into the QM editor, it will automatically place: run "$desktop$\1.txt"